AppConfiguration icon indicating copy to clipboard operation
AppConfiguration copied to clipboard

Recommendations of using Azure app configurations with staging slots

Open Shuvajyoti opened this issue 3 years ago • 2 comments

We are planning to use azure app configurations for our Azure Function app which uses slots in dedicated App service. As of today (without Azure App Configuration), in our CI/CD pipeline we update Configs along with Code changes.

We wanted to know the recommendations for maintaining/updating configurations in Azure App Configurations considering these slots (staging and production). Wanted to know any recommendations on deploying these configs along with our code and also rollback scenarios.

Shuvajyoti avatar Jul 05 '22 11:07 Shuvajyoti

Hello @Shuvajyoti, Azure App Configuration best practices can be found here.

Given everything you described, I think the parts you will find the most relevant are

Your scenario is pretty high-level so the recommendations are high level as well. But to offer an example of how they could be of use, the key-value composition strategy describes how you might use label to override certain settings in your staging slot if that may be useful to you.

Given what you said about how your configuration was tied in with your CI/CD pipeline you may find our existing support for Azure DevOps pipelines to be of use. You can push settings to Azure App Configuration during deployment. You can also pull settings during deployment as a file to package in with your build artifacts.

jimmyca15 avatar Jul 06 '22 16:07 jimmyca15

Thanks @jimmyca15 for the response. We plan to leverage the Push task or CLI commands to push configs as you mentioned above. We are evaluating a few scenarios and would like to understand the following -

Say my pipeline has following tasks -

1.Push/Update App Configurations 2.Deploy Azure Function app to staging slot 3.Run Integration tests which target staging slot 4.Swap slots

Task 1., 2. pass successfully. While running 3., integration tests fail. Now configs are updated but my code is not updated.

Questions - Considering step 3. failed

  1. After step 3 failed, if my function app scales out, will the new instance load the new configs? [This leads to an issue as deployed Code (in production slot) is still having the old bits, but configs are updated]
  2. How do I restore my configs to previous version? [I suppose the restore cli command should be sufficient in this case. Please advise]

Shuvajyoti avatar Jul 11 '22 12:07 Shuvajyoti

Hi @Shuvajyoti, indeed. It will be problematic if your prod and staging share the same set of configurations. If anything goes wrong with your staging, the prod is impacted.

I would recommend you start versioning your configuration. For example, if prod is using v1 of the configuration currently, you set the label v2 (or a build number) when you push data to App Configuration for your staging. Your staging code references only the v2 version of the configuration. This way, when you have to roll back staging, none of the prod v1 configurations is impacted.

zhenlan avatar Sep 12 '22 19:09 zhenlan

Hi, If we want to deploy an app service version n+1 in a second slot, we need in a same time a set of keys/values for versions n (in slot1 in production) and n+1 (slot2), and also for each environment.

If we have 5 environments, and app services with 50 key/values, it's difficult to manage all these configurations in App Configuration. What's more, we can't easily duplicate a set of keys/values. Furthermore, we need to have a single "Dev", "Staging" or "Production" Label, fixed beacause used in CICD to deploy on an environment "Dev", "Staging" or "Production".

Another thing, in the App Settings of an app service, we have a "Deployment slot setting" checkbox which allows us to indicate whether the value is slot-specific or not. This configuration is not currently possible in App Configuration and must be done manually.

So we need improvements in App Configuration to use deployements in slot wtih only on label for each environnement :

  • Have versionning on configuration, to depoy a specific version and not a version at a date-time.
  • Have possibility to set value of the "Deployment slot setting" checkbox for each key/value

Thanks

Philippe85 avatar May 26 '23 09:05 Philippe85

It may not solve all the issues, but I'd like to share an option. You can add App Configuration references in the App Settings of an App Service:

https://learn.microsoft.com/en-us/azure/app-service/app-service-configuration-references

This way, you can indicate if a referenced key-value should go with a deployment slot. Unfortunately, App Service only supports referencing individual key-values in App Configuration today, so it may work well if you have a small number of settings that need to be attached to certain deployment slots.

zhenlan avatar May 26 '23 23:05 zhenlan