Azure / bicep

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

staticSites API is not idempotent -- requires `isForced` query parameter for redeployment #7500

Open itpropro opened 2 years ago

itpropro commented 2 years ago

Is your feature request related to a problem? Please describe.

There is a nearly 1 year old implementation issue in the Static Web Apps (staticSites) provider that blocks idempotent deployments when user defined function apps are used (https://github.com/Azure/static-web-apps/issues/576). The problem is that as soon as the userDefinedFunction property was set once, it cannot be overwritten and the resource provider even throws a error with the exact same configuration because the field seems to be write protected internally. There is a uri parameter called isForced that has to be set to overwrite this property, but it is only available in the REST API (https://docs.microsoft.com/en-us/rest/api/appservice/static-sites/register-user-provided-function-app-with-static-site#uri-parameters) and that should be used like this

PUT https://management.azure.com/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.Web/staticSites/testStaticSite0/userProvidedFunctionApps/testFunctionApp?isForced=true&api-version=2021-02-01

Is there any way in Bicep or ARM templates to reference URI parameters or has anyone an idea of a proper workaround to be able to use IaC with staticSites?

anthony-c-martin commented 2 years ago

Just confirming that there is no capability to add parameters to the PUT query string through Bicep or ARM Templates.

I can't comment on whether there is another workaround for staticSites in Bicep.

itpropro commented 2 years ago

Thanks for confirming @anthony-c-martin! Do you know if there is any guidance for the development of resource providers to avoid uri parameters to be compatible with IaC?

alex-frankel commented 2 years ago

The guidance to all RPs is to make sure all of their resources are deployable via ARM Templates/bicep, so if a query string parameter is required for deployment, they should change that such it is in the PUT request body.

The more concerning part of what you are reporting is that the API is not idempotent. It is ok for a property to not be modifiable, but if there were no property changes then it should re-deploy successfully.

I would recommend opening a support case for this one. @seligj95 / @naveedaz -- do you have a good contact on the static sites team that can help look into this?

itpropro commented 2 years ago

Exactly, I don't think it's a problem in general, if some parameters like isForced are being exposed later with a newer api version, but unfortunately, the parameter is required for idempotency. Thereby it blocks every ARM/Bicep deployment and management of staticSites that have a customer function app deployed. Maybe Terraform would work, as they use REST APIs, but the Terraform provider doesn't have functionality regarding user provided function apps at all. I am currently working on some submodules for CARML for the staticSites provider, if a reproduction repository is needed, I can provide one.

itpropro commented 2 weeks ago

@BandaruDheeraj for visibility