System Administration & Network Administration
powershell azure azure-active-directory
Updated Wed, 18 May 2022 15:14:01 GMT

When trying to Create a New Azure Key Vault using Azure Active Directory Module for Windows Powershell, it always failed


When trying to Create a New Azure Key Vault using Azure Active Directory Module for Windows Powershell, it always failed. This is what I tried:

New-AzureRmKeyVault -VaultName 'Contoso03Vault' -ResourceGroupName 'OMSTest' -Location 'East US'

WARNING: Could not load file or assembly 'Microsoft.Data.Services.Client, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. New-AzureRmKeyVault : Could not load file or assembly 'Microsoft.Data.Services.Client, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. At line:1 char:1 + New-AzureRmKeyVault -VaultName 'Contoso03Vault' -ResourceGroupName 'O ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [New-AzureRmKeyVault], FileNotFoundException + FullyQualifiedErrorId : Microsoft.Azure.Commands.KeyVault.NewAzureKeyVault

Any ideas on this would be much appreciated!




Solution

According to the error log, it seems that you don't use latest Azure Power Shell. You could use following command to get your Azure Power shell version.

Get-Module -ListAvailable -Name Azure -Refresh

The latest version is 4.4.1. You could download the installer file from the link and install it.

Note: Cmdlet New-AzureRmKeyVault is a Azure Power Shell cmdlet not Azure AD Power Shell cmdlet. You should use the cmdlet in Power Shell console not Azure AD Power shell console.

enter image description here