Я запускаю указанную ниже команду azure cli, чтобы получить идентификаторы подписки для определенной группы управления.
Команда:
az account management-group show --name "Simple-NonProduction-EMG-v01" -e -r
Вывод:
{
"children": [
{
"children": null,
"displayName": "TestSub-ABC-Dev",
"id": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"name": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"roles": null,
"type": "/subscriptions"
},
{
"children": null,
"displayName": "TestSubIdentity",
"id": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"name": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"roles": null,
"type": "/subscriptions"
},
{
"children": null,
"displayName": "TestSub-Build-DevTest",
"id": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"name": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"roles": null,
"type": "/subscriptions"
},
{
"children": null,
"displayName": "Azure ITI - TestSub Pre-prod",
"id": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"name": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"roles": null,
"type": "/subscriptions"
},
{
"children": null,
"displayName": "TestSub-IS-Demo",
"id": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"name": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"roles": null,
"type": "/subscriptions"
},
{
"children": null,
"displayName": "TestSub-PQR-QA",
"id": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"name": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"roles": null,
"type": "/subscriptions"
},
{
"children": null,
"displayName": "TestSub-PQR-PreProd",
"id": "/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"name": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"roles": null,
"type": "/subscriptions"
}
],
"details": {
"parent": {
"displayName": "Simple-DMG-v01",
"id": "/providers/Microsoft.Management/managementGroups/Simple-DMG-v01",
"name": "Simple-DMG-v01"
},
"updatedBy": null,
"updatedTime": "0001-01-01T00:00:00",
"version": 0.0
},
"displayName": "Simple-NonProduction-EMG-v01",
"id": "/providers/Microsoft.Management/managementGroups/Simple-NonProduction-EMG-v01",
"name": "Simple-NonProduction-EMG-v01",
"roles": null,
"tenantId": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"type": "/providers/Microsoft.Management/managementGroups"
}
Я запускаю приведенные ниже команды, но она выдает без вывода .
az account management-group show --name "Simple-NonProduction-EMG-v01" -e -r --query [].[children]
az account management-group show --name "Simple-NonProduction-EMG-v01" -e -r --query [].[children.children.name]
az account management-group show --name "Simple-NonProduction-EMG-v01" -e -r --query [].[children.children]
Я не понимаю
- Почему я не получаю вывод.
- Когда использовать квадратные скобки против того, когда использовать одинарные кавычки.
Нет вывода для приведенной ниже команды:
az account management-group show --name "Simple-NonProduction-EMG-v01" -e -r --query 'children.children.name'
Ссылка на использование одинарных кавычек: https://docs.microsoft.com/en-us/cli/azure/query-azure-cli?view=azure-cli-latest
Ссылка на использование квадратных скобок: https://adamraffe.com/azure/2017/11/22/the-wonderful-world-of-azure-cli-jmespath-queries/
Буду признателен за ваш вклад.
Спасибо