admin管理员组

文章数量:1302895

I am running the following command in bash terminal

scope=$(az cognitiveservices account list --query "[?
contains(properties.endpoint, '/')]
 | [0].id" -o tsv)

I have copied it from .sh.

I expect it to run. However, the value of scope is empty which is failing the function assignAOAIRoleToManagedIdentity and interrupting the rest of the bicep script.

Is the command wrong? I am not experienced in the topic. Thus , would appreciate help in understanding what the command is failing and how I fix it.

I am running the following command in bash terminal

scope=$(az cognitiveservices account list --query "[?
contains(properties.endpoint, 'https://aiservices-2025learnresolution760978729403.openai.azure/')]
 | [0].id" -o tsv)

I have copied it from https://github/Azure-Samples/graphrag-accelerator/blob/main/infra/deploy.sh.

I expect it to run. However, the value of scope is empty which is failing the function assignAOAIRoleToManagedIdentity and interrupting the rest of the bicep script.

Is the command wrong? I am not experienced in the topic. Thus , would appreciate help in understanding what the command is failing and how I fix it.

Share Improve this question asked Feb 10 at 12:22 Manu ChadhaManu Chadha 16.8k24 gold badges114 silver badges242 bronze badges 2
  • if you run az cognitiveservices account list, is there an account with endpoint https://aiservices-2025learnresolution760978729403.openai.azure/ ? – Thomas Commented Feb 11 at 5:45
  • Are you trying to retrieve the endpoint details from a specific resource group. Is it works for you! @Manu Chadha – Jahnavi Commented Feb 11 at 7:02
Add a comment  | 

1 Answer 1

Reset to default 0

Getting empty value for scope when running command az cognitive services account list:

You need to filter the query parameter in the below way to retrieve the endpoint of a cognitive service account.

az cognitiveservices account list --query "[].{endpoint: properties.endpoint}"

Condition check for cognitive service endpoint existence:

scope=$(az cognitiveservices account list --query "[?contains(properties.endpoint, 'https://newcog.cognitiveservices.azure/')] | [].{endpoint: properties.endpoint}")
echo $scope

I have also created multiple AI services and tried applying the above logic to test if it is working on multiple services and it worked as expected.

本文标签: azuregetting empty value for scope when running command az cognitiveservices account listStack Overflow