Bicep Deployments to AppService Clears zip/Deployment Center Deployments

122 views Asked by At

I am deploying an AppService environment via Bicep. Everything is working well and is configured exactly as desired.

However, I have noticed that if I redeploy a Bicep template after I have deployed my AppService contents (via ZIP deployment using Azure DevOps), it completely clears all Deployment Center deployments, rendering an empty/default AppService.

Is there a way to stop this from happening? I would prefer to retain the AppService deployed contents and keep them intact.

2

There are 2 answers

0
Mike-E On BEST ANSWER

I finally figured out this issue, and it was a tricky one. The problem was that the WEBSITE_RUN_FROM_PACKAGE environmental variable was not set. I was thinking that DevOps would be responsible for setting this, and it does. However, when the Bicep deployment executes and this property is not part of the configured settings (and I do not merge them with existing values) it gets erased.

5
Alvin Zhao - MSFT On

Assuming your bicep deployment mode is incremental and according to this document,

In incremental mode, Resource Manager leaves unchanged resources that exist in the resource group but aren't specified in the template. Resources in the template are added to the resource group.

When redeploying an existing resource in incremental mode, all properties are reapplied. The properties aren't incrementally added. A common misunderstanding is to think properties that aren't specified in the template are left unchanged. If you don't specify certain properties, Resource Manager interprets the deployment as overwriting those values. Properties that aren't included in the template are reset to the default values. Specify all non-default values for the resource, not just the ones you're updating. The resource definition in the template always contains the final state of the resource. It can't represent a partial update to an existing resource.

Please consider avoiding resetting your App Service by bicep deployment every time after deployment via zip, if it is not required/necessary.