Reputation: 48
The Vault '' not found within subscription even though we have access to the subscription. I am following the documentation and trying to grant access to our Azure Key Vault:
When I try the command to create an access policy for our Key Vault that grants secret permission to our user account, we are getting the following error:
We tried adding the --debug
command as follows; however, we're still unclear as to why our Key Vault is not found under the Subscription ID in our Azure portal:
We used az login
, and it looks like we have access to the correct subscription based off of the output below since the "id" matches our Subscription ID:
Upvotes: 1
Views: 1315
Reputation: 48
Edit: I found how it's suppose to work!
First, you need to make sure you are logged into the correct subscription. https://learn.microsoft.com/en-us/powershell/azure/context-persistence?view=azps-8.2.0
Context is often picked by default and does not always go where you want it to. You can run Get-AzSubscription
to check whether the correct subscription is listed.
Originally, when I ran Get-AzSubscription
in PowerShell, I got the following error:
Turns out you need to install the Az module in PowerShell. You can also try running the command instead: az account tenant list && az account show --output table
Since context is often picked by default and does not always go where you want it to, you can set the default subscription as follows:
After logging into Azure, using e.g. Connect-AzAccount
in PowerShell (version 7+), or whichever command you use to login, you can use the Update-AzConfig -DefaultSubscriptionForLogin <>
command in PowerShell to update the default subscription so that in the future, it will always choose your specified default subscription.
Example of 3 different ways to change the default subscription:
az account set --subscription "XX-XXXXX-XXX-XXX-XXXX-XXX"
Set-AzContext -Subscription 'XX-XXXXX-XXX-XXX-XXXX-XXX'
Update-AzConfig -DefaultSubscriptionForLogin YourSubscriptionNameHere
You can check to make sure the default was changed by using the command:
az account show --output table
Upvotes: 2