az sql server audit-policy returns "nsufficient permissions", but works with Powershell
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
> ### `az feedback` auto-generates most of the information requested below, as of CLI version 2.0.62
**Describe the bug**
**To Reproduce**
* created a new sql db server, storage account and vnet.
* I gave the storage account a private endpoint on the vnet and left network bypass for AzureServices
To enable auditing, I took these steps:
* Created Managed Identity for SQL
```
az sql server update --name sqlauditdemo -g sql-audit -i
```
* Created a Role Assignment on the storage account for the managed identity
```
az role assignment create \
--role "Storage Blob Data Contributor" \
--assignee \
--scope /subscriptions//resourceGroups/sql-audit/providers/Microsoft.Storage/storageAccounts/sqlauditdemoaccount
```
* Set the audit policy
```
az sql server audit-policy update -g sql-audit -n sqlauditdemo --state Enabled --bsts Enabled --storage-account sqlauditdemoaccount
```
This fails with an insufficient permissions error. But, if I run this as Powershell, it works:
```
Set-AzSqlServerAudit -ResourceGroupName "sql-audit" -ServerName "sqlauditdemo" -BlobStorageTargetState Enabled -StorageAccountResourceId "/subscriptions//resourceGroups/sql-audit/providers/Microsoft.Storage/storageAccounts/sqlauditdemoaccount"
```
**Expected behavior**
The CLI command should succeed based on the docs. If the command is missing something or not configured correctly, the docs should be updated.
**Environment summary**
Azure Shell on 11/1/2020
**Additional context**
Contributor guide
Assessment
This issue has not been assessed yet.