Azure / azure-cli

Azure Command-Line Interface
MIT License
3.99k stars 2.96k forks source link

az monitor diagnostic-settings create for App Service with Storage Account archiving throws error #19387

Open alexawka opened 3 years ago

alexawka commented 3 years ago

Describe the bug When assigning Diagnostic Settings for Azure App Service via Azure CLI that has Storage Account for log Archiving enabled, the exception is thrown. Text of the exception - (Conflict) Storage account '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx/resourcegroups/resource-group-name/microsoft.storage/storageaccounts/storageaccountname' is not accessible yet. Try again when storage provisioning is complete. While any other resource can be assigned with same Diagnostic Settings and storage account.

To Reproduce

  1. Create App Service (our scenario is Linux Container)
  2. Prepare Azure Storage account (or scenario is StorageV2 Standard_GRS Cool)
  3. Execute code (variables configured appropriate to the environment): az monitor diagnostic-settings create --name $appName --resource $appId --storage-account $strorageName --metrics '[{"category": "AllMetrics","enabled": true, "retentionPolicy": {"enabled": true, "days": 180 }}]'
  4. Exception is thrown: (Conflict) Storage account '/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxx/resourcegroups/resource-group-name/microsoft.storage/storageaccounts/storageaccountname' is not accessible yet. Try again when storage provisioning is complete
  5. Replace App Service for different service (e.g. KeyVault), run the command and there is no exception
  6. Assign App Service Diagnostic Settings via Portal with same Storage account - no exception

Expected behavior

  1. Create App Service (our scenario is Linux Container)
  2. Prepare Azure Storage account (or scenario is StorageV2 Standard_GRS Cool)
  3. Execute code (variables configured appropriate to the environment): az monitor diagnostic-settings create --name $appName --resource $appId \ --storage-account $strorageName \ --metrics '[{"category": "AllMetrics","enabled": true, "retentionPolicy": {"enabled": true, "days": 180 }}]' \
  4. Diagnostic settings are applied successfully

Environment summary

az CLI verions - 2.27.1 OS - Windows 10 20H2 Shell - bash (git bash)

Additional context

yonzhan commented 3 years ago

monitor

kairu-ms commented 3 years ago

@00Kai0, Please check whether it needs service attention.