(ResourceGroupNotFound) Resource group '????' could not be found when creating an azure media services account
Asked Answered
M

6

54

I'm trying to create a Service Principal account using the instructions here

https://learn.microsoft.com/en-us/azure/media-services/latest/stream-files-tutorial-with-api#examine-the-code-that-uploads-encodes-and-streams

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.

Motto answered 21/11, 2018 at 18:13 Comment(1)
My problem was that I had multiple subscriptions for the account and I needed to set the subscription related to the resource group firstMotto
S
148

If you have multiple subscriptions, set your subscription first and then try:

  • To list all subscriptions - az account list --output table
  • To set your subscription - az account set --subscription <subscription-id>
  • To set your subscription using Powershell - Set-AzContext <subscription_id>
Shady answered 28/11, 2019 at 4:58 Comment(5)
In Azure Powershell, I needed to run "Set-Azcontext <subscription_id>" in order for my subscription to change - as per @ddmh's answer. - However your answer made me aware of the reason for my error, thanks :)Yasminyasmine
When you run "az account list" as shown, check which subscription ID is set with IsDefault true. It is probably not the one you want, so the "az account set" command is used to change to the correct subscription, then your command that was failing to find the resource group will probably work. I found this useful on "az vm deallocate" when it said it couldn't find the resource group - changed to the correct subscription, and the vm deallocate worked as required.Wikiup
The set subscription solved my issue. It is strange that I am using command "az network nsg rule list" and I even added parameter --subscription to it, but still failed.Trahan
worked for me too Set-Azcontext <subscription_id>Dewar
It worked for me. Because my account has 3 subscriptions, the first one doesn't have the resource group. Thanks a lot.Shalne
P
13

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>

Polyhedron answered 19/11, 2021 at 9:44 Comment(0)
C
12

Kindly follow these steps to get over an above error:

  1. az login It will ask you to provide credentials

  2. 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

Cermet answered 15/10, 2019 at 18:56 Comment(1)
Item 2. should end -o table or --output table (Sorry can't edit)Qualify
T
7

You may have multiple subscriptions. Set the subscription to default which you want to use in CLI.

Reference: https://learn.microsoft.com/en-us/cli/azure/manage-azure-subscriptions-azure-cli?view=azure-cli-latest

Tehee answered 20/6, 2019 at 20:54 Comment(4)
Welcome to StackOverflow! Please include helpful lines of code and plenty of explanation in your answers. You can distinguish a line of code with two accents (`) on either side of the code, to render a result like this.Cornelie
Thank you for this answer! A simple thing like this - left off the Azure documentation walk-through I was using (re. opening a command-line connected to an Azure Kubernetes cluster) - resolved hell for me being unable to "see" the resource group. For others, from the link provided, set the Azure account as follows: az account list --output table to view a list of accounts - and - assuming the desired account is in the list - issue az account set --subscription "<account name>", at which point, for me at least, the Resource group not found error went away.Racemic
Thank you very much for this answer. Saved me hours of research.Oralle
microsoft links are anything but permalinks. please include the actual answer in your answer i.e,. the cli command to set a default subscriptionHurt
W
6

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.

Weissmann answered 10/3, 2022 at 22:4 Comment(0)
C
1

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!

Caltanissetta answered 22/11, 2018 at 1:20 Comment(5)
I think I may be confused as to what resource group is being talked about. If I run az group list I only see one resource group but if I login into the Azure dashboard with the same account there are 36 resource groups but not the one listed by the Azure CLIMotto
Either way whichever resource group name I use I always get the same messageMotto
Did you check to make sure you were logged into the right subscription via both the portal and the CLI? Otherwise, it may be a permission issue on your subscription.Caltanissetta
Try "az account show" and make sure the account you are logged into in the CLI is the right one.Caltanissetta
I just re-checked, and was able to run this successfully in my own MSDN account. So if you are hitting an error, you may want to pen a support ticket on your subscription. az ams account sp create -a build18 --resource-group build2018 --role Owner --years 2Caltanissetta

© 2022 - 2024 — McMap. All rights reserved.