Which settings should Azure App Service pre-production slot use? - azure

I have 3 App Service slots in Azure:
ExampleName (Production)
ExampleName/master
ExampleName/staging
CI/CD is configured this way:
on push to branch 'master' deploy to 'ExampleName/master' slot
on push to branch 'staging' deploy to 'ExampleName/staging' slot
I read about deployment best practices in Azure docs and they say that:
Continuous deployment should never be enabled for your production
slot. Instead, your production branch (often main) should be deployed
onto a non-production slot. When you are ready to release the base
branch, swap it into the production slot.
I am new to this and quite confused about which settings should the "ExampleName/master" slot use before swapping slots? Should it use the production database and other services? Or it should use the ones from the staging environment?
Since the version of the already running app in the production slot can be different from "/master" one I am thinking that it shouldn't use the production one, but don't know if I am right or not.

You should use different app services for your prodcution and non-production workload. Because behind the scene they use the same resources. So making stress test on your non-production slot you may take entire site down.
The prhase prodution slot and stagind slot doesn't refer to environments. They just saying that one slot is main and serve traffic. It is used to minimize downtime. So first you may publish your app to staging slot, you can make small tests to be sure that all is fine and swap slots. But this is not designed for becoming and environment.

Related

Terraform on Azure - how to do blue/green deployment with deployment slots with no downtime?

How can I do blue/green implementations with TF, Azure App Services and Function Apps, and deployment slots? If you update both slots as part of the pipeline, couldn't you end up with downtime on the prod slot?
Conceptually, wouldn't you only want to make these changes to the staging slot to ensure things are good? But then what happens, because there are many settings that aren't swapped. At some point you need to apply these changes to the live site. How can you be confident that you won't cause an outage?
I like the concept of deployment slots, but I can't figure out how to get around this.
Is a better long-term solution to have multiple web/function app instances (no slots) behind a load balancer? You could pull an instance out of the pool, update it, then when you're happy with the outcome, put it back in the pool and direct traffic to that newly updated resource.
I have my pipeline setup to create my TF plan and apply it then deploy code to the staging slot and run smoke tests. If they pass, the slots are swapped and another smoke test is run on the production slot.
In theory this is ok, but if there are any configuration changes for the production slot in the TF script, they will get applied to the live resource, which could cause downtime if it's misconfigured.

how can we transform entire web.config from staging slot to production slot in azure?

I have created multiple slots(test, stage and prod) in my azure app service. Similarly I have created respective web.config files for each environment. I am deploying my application through octopus deployment tool in test environment slot, so initially it's picking web.test.config file and it's working fine.
But, I want to swap complete transformation section of web.config file when I swap it to stage or Prod slot while doing swapping through azure portal. Is there any way to do ?
using application setting and connection string of configuration setting, I am able to segregate the setting of each slot. But I am not sure how can I do it for other section like system.identityModel,system.web system.identityModel.services, etc. Therefore I want to replace complete transformation section according to environment while doing swapping.
When I talked with the app service team, they said slots are not meant for this purpose. The main purpose of slots is to allow deployment of new versions with little or no downtime. Or to test new features with a small percentage of the traffic. Not really for different environments, you should use have separate app services for that, to which you deploy separately.

Emulate Azure web app like slots supporting "swap" for on premise IIS10

In azure you can have slots that you can deploy your web app to.
For example you can have Production and Staging slots.
You can deploy to Staging then test if everything is OK and if so swap Staging with Production slot.
I believe that behind the scenes those slots are just 2 sites in IIS.
My idea is to just swap bindings and rename the websites so the Staging slot/website will get http://prod-superapp.com binding and the Production slot/website will get http://stg-superapp.com binding then rename Production website to Staging and Staging to production.
The last step is needed so that when we deploy the next time we deploy to the Staging slot again.
Can you think of anything better than this? Do you find any problems with that approach that I am currently not aware of? I know that there can't be two site with the same binding running at the same time so that scheme will have some downtime while the whole process completes.

How does Swap slot works in azure portal

We have two web APIs hosted on azure for staging and production.
And we are consuming those APIs in mobile app where we provided which API should be used.
Right Now we are testing with staging app with staging mobile app.
If we do production app deployment and do swap slot from staging to production, does it will affect the staging app.
We have 2 different versions on hockeyapp staging and production mobile app. After swap slot does staging app will still point to staging API?
Should we standard API publish method.
Any help on this appreciated !
Slot swap switches the apps to the other slot.
So the app version in production will be running in staging and the one which was running in staging is now in production.
In my opinion you are using them a bit wrong here.
The purpose of deployment slots is to allow a "staged deployment" where new code can be published to the slot without bothering production, and then hot-swapped with minimal downtime.
What you really need is a testing environment, which you target from your testing app.
When deploying you deploy to staging and then swap to production.

How does Azure Deployment switch works from staging to production?

I heard that there will be no session time out happens when the deployment switch happens in Azure from staging to production. Is my understanding correct?. If so how Azure handles internally this switch?.
The answer depends on what switch form staging to production you're talking about. Because you could use Deployment Slots like this, but it is not recommended to have a full-blown Staging environment as a slot on your App Service. Since these slots run on the same App Service Plan as Production, heavy load on Staging could hurt Production performance.
I tend to think of it more as a 'Pre-Production' environment using a Deployment Slot where you can do some last checks (smoke test) before you release the new version of your application into the wild.
I would think sessions are managed internally since the two slots run on the same App Service Plan, making this a relative simple scenario.
Documentation
Deploying an app to a slot first and swapping it into production ensures that all instances of the slot are warmed up before being swapped into production. This eliminates downtime when you deploy your app. The traffic redirection is seamless, and no requests are dropped as a result of swap operations.
Find more information about using slots here: Set up staging environments in Azure App Service

Resources