Question: Why I am getting the following error in the last line of powershell
script shown below - and how can we fix the error? I have double checked by copying/pasting the resource group (RG)
name from Azure Portal to verify that the RG name is correct:
Get-AzStorageAccount: Resource group 'rg-e-testdataanalytics-dev-01' could not be found
# these are for the storage account to be used
$resourceGroup = "rg-e-testdataanalytics-dev-01"
$storageAccountName = "myStorageAccount"
# get a reference to the storage account
$storageAccount = Get-AzStorageAccount -ResourceGroupName $resourceGroup -Name $storageAccountName
Most likely you might be in wrong Azure Context. To verify this run the command Get-AzContext
, which will return the Active Directory account, Active Directory tenant, Azure subscription, and the targeted Azure environment.
Azure Resource Manager cmdlets use these settings by default when making Azure Resource Manager requests. So make sure you are in correct Active Directory account/Active Directory tenant/Azure subscription/Azure environment.
If you are in wrong subscription, you can set the subscription context by
Set-AzContext -Subscription "xxxx-xxxx-xxxx-xxxx"