Azure / container-apps-deploy-pipelines-task

Azure Pipelines Task (Release Candidate) for building and deploying Azure Container Apps
MIT License
6 stars 10 forks source link

Staging vs. Production etc. how to set environment variable #29

Closed dyardy closed 1 year ago

dyardy commented 1 year ago

I am using the following pipeline to deploy asp.net api to container. The solution builds a dockerfile.

I have 2 environments (and container app in production and same one in staging).

What is the best approach to ensure ASPNETCORE_ENVIRONMENT variable is set as Staging or Production with each deployment?

a) do i setup a docker file for each environment and 2 pipelines? b) do i set environment variable within the azure container app resource? c) can I use the same pipeline and set some variable with each

The goal is to setup easiest approach for setting this environment variable as part of the deployment preferrably? (setting a container app env variable is very manual)

steps:

cormacpayne commented 1 year ago

@dyardy Hey there, the AzureContainerAppsRC task offers an environmentVariables argument that allows you to provide key-value pairings that are set as environment variables on the Container App that you're targeting. This would allow you to set the ASPNETCORE_ENVIRONMENT variable to "Staging" or "Production" depending on the Container App you're deploying.

For the other set of questions you've provided around the actual deployment of two different environments:

do i setup a docker file for each environment and 2 pipelines?

You should be able to reuse the same Dockerfile for both Staging and Production, and having one pipeline vs. two depends on how you do deployment, testing, etc. If you envision the flow of deploying to Staging and Production to be the same, you can reuse a base pipeline that has different secrets and variables provided depending on the environment you're targeting for deployment.

do i set environment variable within the azure container app resource?

This should be answered with the environmentVariables comment made above.

can I use the same pipeline and set some variable with each

This should be answered in the response to your first question above.

It's ultimately up to you and your specific use-case on how you want to deploy to and test Staging and Production environments, but if you don't envision any differences in the code you're deploying, how you're testing it, etc., then it's probably not a bad idea to create a base pipeline that you can reuse for both environments with different secrets and variables.

cormacpayne commented 1 year ago

@dyardy Hey there, I'm going to close this issue as there doesn't seem to be any actionable items on our side, but please feel free to let me know in a follow-up comment if you'd like me to re-open this issue or have any additional questions.