The term ‘New-AzureStorageContext’ is not recognized

In this Azure tutorial, we will discuss how to fix the error. The term ‘new-azurestoragecontext’ is not recognized as the name of a cmdlet.

The term ‘New-AzureStorageContext’ is not recognized as the name of a cmdlet

I got the above error while uploading the file into the Azure container using the below cmdlet using Powershell ISE.

$Keys = "Coro2SvGOTD+nT3YdaKCrnauzWvHMF6BmuD9PfSKtNJWt6etXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=="
$StorageContext = New-AzureStorageContext -StorageAccountName sqlvaqrc7kssdx4eus -StorageAccountKey $Keys
$containerName = "democontainer";
Set-AzStorageBlobContent -File "D:\Bijay\Upload9.txt" `
  -Container $containerName `
  -Blob "Upload9.txt" `
  -Context $StorageContext 
The term New-AzureStorageContext is not recognized

The exact error message was “The term ‘New-AzureStorageContext’ is not recognized as the name of a cmdletfunction, script file, or operable program. Check the spelling of the name or if a path was included, verify that the path is correct, and try again.

At line:3 char:19

+ $StorageContext = New-AzureStorageContext -StorageAccountName sqlvaqrc7kssdx4eus -StorageAccountKey $Keys

New-AzureStorageContext is not recognized – Fixed

To fix the above error, You need to follow the below steps

1. Run your PowerShell ISE or Windows PowerShell as an administrator mode

new-azstoragecontext is not recognized

2. Use the below cmdlet to install the AzureRM module

PS C:\WINDOWS\system32> Install-Module AzureRM -AllowClobber
the term 'new-azstoragecontext' is not recognized as the name of a cmdlet

3. Click the Yes button on the below popup to confirm the installation.

new-azurestoragecontext not recognized

4. You can see below it started installing the AzureRM module

new-azurestoragecontext

Please wait for a few minutes. It will complete the installation of the AzureRM module.

Now, you can execute the below cmdlet to upload the file into the Azure container. This time, I didn’t get that error.

$Keys = "Coro2SvGOTD+nT3YdaKCrnauzWvHMF6BmuD9PfSKtNJWt6etXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=="
$StorageContext = New-AzureStorageContext -StorageAccountName sqlvaqrc7kssdx4eus -StorageAccountKey $Keys
$containerName = "democontainer";
Set-AzStorageBlobContent -File "D:\Bijay\Upload9.txt" `
  -Container $containerName `
  -Blob "Upload9.txt" `
  -Context $StorageContext 

Check out the New-AzureStorageContext PowerShell command for more information.

You may like the following Azure tutorials:

Conclusion

In this Azure tutorial, we discussed fixing the error: “The term ‘New-AzureStorageContext’ is not recognized.” I hope it will help you to fix your issue as well.