Exported ARM template that includes StorageAccount can't be re-deployed
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 3.5k
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 60
Description
## Describe the bug
An ARM template generated from any resource group that includes a StorageAccount fails when redeploying with an `InvalidXmlDocument` error.
**Command Name**
`az deployment group create`
**Errors:**
```
{"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"BadRequest","message":"{\r\n \"error\": {\r\n \"code\": \"InvalidXmlDocument\",\r\n \"message\": \"XML specified is not syntactically valid.\\nRequestId:e878d855-f01a-005d-286e-b197b2000000\\nTime:2021-09-24T18:00:42.5358098Z\"\r\n }\r\n}"}]}}
```
## To Reproduce:
Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.
```
#!/bin/bash
rand=$RANDOM
az group create -g group${rand} -l westeurope
az storage account create -g group${rand} -n stor${rand}
az group export -g group${rand} --skip-all-params >group-arm.json
az group delete -y -g group${rand}
rand=$RANDOM
az group create -g group${rand} -l westeurope
az deployment group create -g group${rand} -f group-arm.json
```
This fails at the:
- `az deployment group create -g {} -f {}`
## Expected Behavior
Should not fail. According to internet searches this is related to `"type": "Microsoft.Storage/storageAccounts/xxxServices"` entries in the generated ARM template, but then either:
a) they should not be generated if they are not needed
b) `az` should be able to handle the resulting template correctly
## Environment Summary
```
Linux-5.10.43.3-microsoft-standard-WSL2-x86_64-with-debian-10.10, Debian GNU/Linux 10 (buster)
Python 3.7.3
Installer: PIP
azure-cli 2.28.1
```
## Additional Context
A template saved through the Azure portal has the exact same issue
Contributor guide
Assessment
This issue has not been assessed yet.