Import-Module Azure fails

Solution 1:

The Windows Azure SDK binaries and pertaining PowerShell cmdlets are all 32-bit, which is why the "Windows Azure Powershell" shortcut always launches a 32-bit shell.

You can import the Azure module to an existing PowerShell session by referencing the filesystem path to the module manifest:

Import-Module "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1"

[Update] In latest Azure, use

Import-Module "C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement\Azure\Azure.psd1"

To access the module by name alone, you'll need to include its location in the PSModulePath environment variable (here in excruciating detail, for developers):

$oldPSModulePath = [Environment]::GetEnvironmentVariable("PSModulePath")

$azureModulePath = "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\"

$newPSModulePath = $oldPSModulePath,$azureModulePath -join ";" 

And a shorthand expression for your powershell

$env:PSModulePath += ";C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\"
Import-Module Azure # <-- Now you can do this!

You could include the above in your PowerShell profile

Solution 2:

If you just installed the Azure PowerShell SDK, then restart the computer first. A restart is required after installation, otherwise this exception will be thrown.