I was trying out the public preview of the Azure Key Vault service that has been released recently. While following the steps as mentioned in their blog, came across the below error when trying the ‘New-AzureKeyVault’ command.

Please install Azure Powershell module version 0.8.13 or newer.

I did have the latest powershell for azure installed, but still this error is thrown.

azure powershell installed version

Exploring the powershell scripts for key vault, below is where the error is thrown from ‘Common.ps1’. The script looks for the AzureResourceManager, which got introduced in poweshell version 0.8.0 and lets you manage resources in a completely different way.

1
2
3
4
5
6
7
8
9
10
Function Azure-Version-Check{
    $expectedMinVersion = New-Object -TypeName System.Version -ArgumentList "0.8.13"

    $azureModule = Get-Module AzureResourceManager

    if ((-not $azureModule) -or ($azureModule.Version -lt $expectedMinVersion))
    {
        Throw 'Please install Azure Powershell module version 0.8.13 or newer.'
    }
}

When you use the Azure PowerShell cmdlets, the Azure module is imported into the session by default. To remove the Azure module from the session and import the AzureResourceManager and AzureProfile modules, use the Switch-AzureMode cmdlet.

This is what is exactly causing the issue, we need to switch to use the azure resource manager. Running the below command and trying the ‘New-AzureKeyVault’ command works like a charm

1
Switch-AzureMode -Name AzureResourceManager

You would face this issue only if you started trying out the steps as mentioned in the azure key vault blog(as I did), since the steps in the documentation site is updated with the above step.*

Comments