Understand what happens when using Azure deployment slots, what settings are exchanged between slots, and how to swap and rollback apps.
- [Instructor] Typically, we never want to deploy a web app, mobile app, or app service directly into production. In Azure, we can deploy the deployment slots, test, and then release to production. I like to think of deployment slots, as staging areas. Let's take a look at the workflow when we use deployment slots in Azure. First, we have our production app. This app is handled in request by our users. But the application needs to be updated for whatever reason.
We've worked with our app and now we're going to upload the modified app into a staging area or deployment slot. Now that the app has been deployed to the staging slot, we can go ahead and test it. Once testing is complete and we are satisfied that the application is behaving as we expect it to, we can go ahead and swap out our staging production, deployment slots. Our production slot now becomes our staging and our staging becomes production and the users are unaware of this transition.
Now let's take a look at rolling back an application. And our example here, an application is not behaving as expected. So we've gone ahead and we've had our production staging and we've swapped those out, but all of a sudden our users start noticing errors and we now know we have to swap these back. So what we can do is go ahead and swap them back and now our staging becomes production and production now becomes staging once again.
And we can go ahead and correct the error and run through the process one more time. It's important to understand what is swapped when we do swap our deployment slots. All the general settings are swapped. The connection strings and handler mappings, we'll be talking about these later in the course. The monitor settings, as well as diagnostic and app settings are also swapped out. And the web jobs content. Again, most of these we'll cover off later in the course. Probably more importantly is to understand what is not swapped when you swap out your deployment slots.
First of all, your custom names are not swapped. Your scale settings are not swapped out and neither are your SSL certificates and bindings. The publishing endpoints are not swapped and neither are the web job schedulers. Again, we'll be talking about all of these a little bit later on in the course. As you can see, I have logged into Azure and we are currently looking at the deployed web apps resource group. I'd like to add in a deployment slot. I'm going to go ahead and click on our app.
Is named Prod web app and to create a deployment slot you will go ahead and click Deployment Slots under App Deployment. This will open up the slots blade. We don't have anything here yet, therefore we're going to go ahead and click Add Slot. And then I'm going to provide a name. (typing) I'm going to call it Staging. And you'll notice here that the web app will have a different url.
That means you can test this without affecting the production url that is currently running. If you'd like to go ahead and add in a source to be cloned from, you can do so. You can clone from an existing deployment. Or you do not have to clone anything at all. I'm going to go ahead and take the first option and click Okay. This will take a few moments. There it is. It takes a few moments for the deployment slot to be created and as you can see, ours is now off and running.
If we take a look at it, we can see that our url is slightly different here. So we have prod, web app. I've been staging. Staging coming from the name of the deployment slot. If I want to go ahead the swap this, I can easily do so but clicking on Swap. And my first option is Swap Type. We can do a swap or swap with a preview. You choose a swap with a preview in Mission Critical applications.
When using the preview mode, all of the settings are validated before the swap takes place. In our case, I'm just going to go ahead and pick Swap. Next, select your source. In our case, we're going to take staging. I can not swap production for production. And our destination will be production. You can see me create a production deployment slot. That deployment slot was created when we created the app itself but it's just not visible until now.
Next, go ahead and click Okay. It will take a few moments for the swap to occur. During that time, we can see that our status indicates that it's swapping. And you will not be able to make any changes to your application during this time. Please keep in mind, deployment slots are only available in the standard and premiums schemes. Our swap has now been completed.
And if for some reason, I needed to swap this back, let's go with the example that all of a sudden our users are saying, "Oh, you know what? "Something's not right here. "We need to roll back to the other version." You can easily do so by swapping them back again. And you'd run through the same process by clicking your Swap Type, the source, and destination. I'm going to go ahead and close that blade. And let's take a look at this at the resource group level. In going to close the blade for staging.
And for the deployment slots, next I'm going to go ahead and refresh the resource group and you will notice now that we have another app called Staging. And that's all there is to creating and swapping your deployment slots.
- Deploying Web Apps
- Creating App Service plans
- Deploying and moving apps
- Configuring app settings
- Managing Web Apps using PowerShell and CLI
- Configuring alerts
- Enabling diagnostic logs
- Retrieving and streaming logs
- Configuring Web Apps for scale and resilience