Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.2k stars 742 forks source link

Guidance: how to handle storage in Azure regions that add Zone support? #10734

Closed MaurGi closed 1 year ago

MaurGi commented 1 year ago

Is your feature request related to a problem? Please describe. We have dozens of storage accounts in an Azure region. At the time they were created, there was no Zone support, so they are Standard_LRS. We detect if the region supports zones at runtime and pass the LRS vs ZRS to the ARM template as a parameter.

Now the region has added zone support. All of our ARM and Bicep templates fail because they try to update existing storage accounts to ZRS:

StorageAccountTypeConversionNotAllowed - Storage account type Standard_LRS cannot be changed to Standard_ZRS.

What is a clean way to handle this in Bicep without having to list the regions and storage accounts that need to make exceptions? We are constantly expanding as the region grow and our code needs to be region-independent.

Describe the solution you'd like If I could tell ARM or Bicep to ignore specific changes on existing resources or even avoid touching specific resources if they exist it would solve my problem.

This is easy with az cli: if az exists then skip else az create ..

Wonder how I can achieve the same result with declarative.

stephaniezyen commented 1 year ago

One work around for this is to open a support ticket/ICM and ask the storage team to move all of your storage accounts from LRS to ZRS. The other option is to delete and re-create if you have transient data.

asilverman commented 1 year ago

@stephaniezyen - I think @MaurGi here is not looking for the solution provided, my understanding of this ticket is that @MaurGi would like to request a feature that enables him to conditionally express an update on the given resource by inspecting the existence of the resource. In other words:

If the storage account exists, then don't try to apply the PUT request to change its account type from Standard_LRS to Standard_ZRS.

Do we have a capability to express the above in a Bicep file already?

alex-frankel commented 1 year ago

I think we can close this as a duplicate of #4023. @maurgi, can you take a look and see if that capability would cover it?

FWIW, terraform has something similar via ignore_changes: https://developer.hashicorp.com/terraform/language/meta-arguments/lifecycle

stephaniezyen commented 1 year ago

Closing as a duplicate and no response.