> -ServerName "" ` >> -DatabaseName "" ` >> -BlobStorageTargetSta" /> > -ServerName "" ` >> -DatabaseName "" ` >> -BlobStorageTargetSta" /> > -ServerName "" ` >> -DatabaseName "" ` >> -BlobStorageTargetSta"/>

Azure CLI - How to get ResourceId of an storage container?

3k views Asked by At

I am trying to run this command

Set-AzSqlDatabaseAudit `
>> -ResourceGroupName "" `
>> -ServerName "" `
>> -DatabaseName "" `
>> -BlobStorageTargetState Enabled `
>> -StorageAccountResourceId "?"

To setup auditing on SQL database but I am not able to find a way how to get resource id of storage container I already created for this purpose. I don't see this property in the GUI and also I don't know how to retrieve it via CLI.

Is there some general way how to get resource id of an object or where do I find it?

1

There are 1 answers

0
Joy Wang On BEST ANSWER

The command Set-AzSqlDatabaseAudit you are using is azure Powershell, not azure CLI, so if you want to Powershell to get the StorageAccountResourceId, just use the command below.

(Get-AzStorageAccount -ResourceGroupName <group-name> -Name <storageaccount-name>).Id

enter image description here

If you want to use azure CLI, just use az storage account show, the id is what you want.

az storage account show --resource-group 'xxxxx' --name 'xxxxx'

enter image description here