Reputation: 3117
My question is similar to this one regarding how to set up different React environment variables/app settings during deployments to different environments in Azure Devops.
These are (hopefully) my requirements
I would like to do all this without hard coding any apps settings in my build .yaml
or as build pipeline variables. The reason is if my environment hasn't yet been created by the release pipeline, how would I know what settings to inject when building the react app in the preceding build pipeline?
Is Azure App Configuration a good fit for this?
I figured I could do something like...
Does this sound possible? A good idea?
I feel like this should work in theory. It doesn't matter whether the ARM template for example creates API_URL = https://test.azurewebsites.net or https://prod.azurewebsites.net, because the connection string and label of 'test' or 'prod' was passed into the react app during build, it will always have the correct values at runtime. A few downsides are the App Configuration connection string will need to be exposed as a build pipeline variable, it will need to have been created first, and I would need to implement logic in my react app to switch between loading app settings locally and from the client library
Many thanks,
Upvotes: 1
Views: 2107
Reputation: 1838
An artifact (the build output) should be independent from your stage. You should always use the same artifact for any stage.
The most common way is to provide a server side-response with the client app configuration as json. Load the json on react init and inject your configuration. There is no other way to have.
Both, the client app and the config server app can run in the same app container. You can achive this behavior both with Azure App Service and Azure Static Sites.
Upvotes: 0