Azure / azure-cli

Azure Command-Line Interface
MIT License
3.92k stars 2.88k forks source link

`az resource show -t Microsoft.Sql/servers/databases` not recognized #15896

Open jochenvw opened 3 years ago

jochenvw commented 3 years ago

I'm writing a script to retrieve the resource id from my SQL database. However - az resource show does recognize the database type.

Using the ID found in the portal JSON view of the resource I do:

az resource show --id [removed]/providers/Microsoft.Sql/servers/filetrnsfrm-dbsrv-dev/databases/filetrnsfrm-db-dev

Which returns

{
  "id": "/subscriptions/[removed]/providers/Microsoft.Sql/servers/filetrnsfrm-dbsrv-dev/databases/filetrnsfrm-db-dev",
  "identity": null,
  "kind": "v12.0,user,vcore,serverless",
  "location": "West Europe",
  "managedBy": null,
  "name": "filetrnsfrm-db-dev",
  "plan": null,
  "properties": {
    ...
    "status": "Online",
    "zoneRedundant": false
  },
  "resourceGroup": "ms-csu-nl-jvw-filetrnsfrm-dev",
  "sku": null,
  "tags": null,
  "type": "Microsoft.Sql/servers/databases"
}

Now, using the exact resource-group, name and type as provided in the previous:

az resource show -g ms-csu-nl-jvw-filetrnsfrm-dev -n filetrnsfrm-db-dev --resource-type Microsoft.Sql/servers/databases

Gives

ResourceNotFoundError: The Resource 'Microsoft.Sql/servers/filetrnsfrm-db-dev' under resource group 'ms-csu-nl-jvw-filetrnsfrm-dev' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix

So 'databases' seems to be nested under 'servers' - and in the error message it appears to me as if it's looking for servers named filetranfrm-db-dev as opposed to a database with that name. However, I couldn't find anything in the docs what I need to differently, unless it's the --parent parameter ?

yonzhan commented 3 years ago

ARM