az sql db export demanding subscription wide scope
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
**Describe the bug**
I am using a managed identity on a virtual machine to export a database to a storage container (command "az sql db export"). The managed identity has "Contributor" role on the database. The operation is failing with this error
`The client 'my-identity-id' with object id 'my-identity-id' does not have authorization to perform action 'Microsoft.Sql/locations/importExportAzureAsyncOperation/read' over scope '/subscriptions/my-subscription-id' or the scope is invalid.`
I don't think any identity should ever need subscription wide permissions to export a database.
Remarkably, the database is still exported and the bacpac file can be found on the storage after the command failed.
**To Reproduce**
* create a sql server and a sql database
* create a managed identity
* give the managed identity contributor role on the sql server
* as the managed identity, try to export the database to a storage (https://docs.microsoft.com/en-us/cli/azure/sql/db?view=azure-cli-latest#az_sql_db_export)
**Expected behavior**
The export command should not fail. The managed identity should not require any permission on subscription level.
**Environment summary**
Linux-5.4.0-1031-azure-x86_64-with-debian-buster-sid
Python 3.6.10
Installer: DEB
```
$ az version
{
"azure-cli": "2.14.1",
"azure-cli-core": "2.14.1",
"azure-cli-telemetry": "1.0.6",
"extensions": {}
}
```
**Additional context**
After creating this issue If found [this report](https://developercommunity.visualstudio.com/content/problem/1220563/service-connection-suddenly-lost-permission-for-mi.html), could be related.
Contributor guide
Assessment
This issue has not been assessed yet.