Reputation: 807
I'm trying to create a Service Principal account using the instructions here
However when I run the command
az ams account sp create --account-name *media_service_account_name* --resource-group *resource_group_name*
Where media_service_account_name is the name shown for the media service I have created and resource_group_name the name of the resource group shown on the same page.
The problem is I get the message ResourceGroupNotFound
:
Resource group 'resource_group_name' could not be found.
I just can't see what I am doing wrong. Any help appreciated.
Upvotes: 57
Views: 94361
Reputation: 11
I was struggling with this error while trying to test some bicep templates i was previously using. every result searching for this error had the same "set your default subscription" answer, which did not work.
I finally found this answer where the error is caused by having a non-existent (deleted) default group set, fixed with:
az configure --defaults group=
(unset the default or you can enter the name of a group you'd like to use)
Posting it here since this is the first thing that comes up in google
Upvotes: 1
Reputation: 1531
If you have multiple subscriptions, set your subscription first and then try:
az account list --output table
az account set --subscription <subscription-id>
Set-AzContext <subscription_id>
Upvotes: 153
Reputation: 71
I was running a task: AzureCLI@2
in azure pipeline
for creating an azure vwan.
I put az account set --subscription xxxxxxx-xxxx-xxx-xxxx-xxxxxxxxx
but it still didn't work and was throwing:
ERROR: (ResourceGroupNotFound) Resource group 'test-rg' could not be found.
Then I added --subscription "xxxxxxx-xxxx-xxx-xxxx-xxxxxxxxx"
at the end of he az network vwan create
even though it wasn't shown in the documentation.
Here's how I did:
az network vwan create --name testwan01 --resource-group test-rg --subscription "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" --type Standard
Hope it helps if you are running it from some orchestration tools like Jenkins or Azure pipelines.
Upvotes: 7
Reputation: 353
I had the same issue and verified the subscription with az account show, but what I was missing is that I was working in powershell and needed to set the correct subscription in powershell. Verify context: Get-Azcontext Set context: Set-Azcontext <subscription_id>
Upvotes: 13
Reputation: 1107
Kindly follow these steps to get over an above error:
az login
It will ask you to provide credentials
az account list --o table
// Will list all subscription
Set your subscription on which you want to execute query
3. az account set --subscription
"VS Subscription"
Hope it will help
Upvotes: 13
Reputation: 71
You may have multiple subscriptions. Set the subscription to default which you want to use in CLI.
Upvotes: 7
Reputation: 2512
Keep in mind that Resource Groups in Azure are things that you create, so the article was only providing an example of a Resource Group name.
The command to create the service principal expects you to use the resource group that you used to create your media service account.
az ams account sp create --account-name amsaccount --resource-group **amsResourceGroup**
Make sure that you are using the right resource group name that you used when you created your Media Services account first, and use a unique named one in the same region as your account. I usually call az group create before creating a new account to put it into it's own Resource Group along with the storage account I create for it.
Example Create a new resource group named "MyResourceGroup" in the West US region.
az group create -l westus -n
Hope that helps!
Upvotes: 2