Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Developing Solutions for Microsoft Azure AZ-204 Exam Guide

You're reading from   Developing Solutions for Microsoft Azure AZ-204 Exam Guide A comprehensive guide to passing the AZ-204 exam

Arrow left icon
Product type Paperback
Published in May 2024
Publisher Packt
ISBN-13 9781835085295
Length 428 pages
Edition 2nd Edition
Tools
Arrow right icon
Authors (2):
Arrow left icon
Paul Ivey Paul Ivey
Author Profile Icon Paul Ivey
Paul Ivey
Alex Ivanov Alex Ivanov
Author Profile Icon Alex Ivanov
Alex Ivanov
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

Preface 1. Chapter 1: Azure and Cloud Fundamentals 2. Chapter 2: Implementing Azure App Service Web Apps FREE CHAPTER 3. Chapter 3: Implementing Containerized Solutions 4. Chapter 4: Implementing Azure Functions 5. Chapter 5: Developing Solutions That Use Cosmos DB Storage 6. Chapter 6: Developing Solutions That Use Azure Blob Storage 7. Chapter 7: Implementing User Authentication and Authorization 8. Chapter 8: Implementing Secure Azure Solutions 9. Chapter 9: Integrating Caching and Content Delivery within Solutions 10. Chapter 10: Monitoring and Troubleshooting Solutions by Using Application Insights 11. Chapter 11: Implementing API Management 12. Chapter 12: Developing Event-Based Solutions 13. Chapter 13: Developing Message-Based Solutions 14. Chapter 14: Accessing the Online Practice Resources 15. Other Books You May Enjoy

Exercise 7: Mastering Deployment Slots

In this exercise, you will look at the advanced features of Azure App Service by creating and managing deployment slots:

  1. From the Azure portal, open the Configuration blade within your App Service and notice CURRENT_SLOT has been configured to be a slot setting.

    This means that regardless of any deployment slot swapping that might occur, this setting will not follow the apps. Whatever app is in the production slot will get this production value. ORIGINAL_SLOT, however, isn’t a slot setting so will follow the app through a swap. You’ll see this momentarily.

  2. Go to the Deployment slots blade and click Add Slot. Enter staging for the name of the deployment slot and choose to clone the settings from the default/production slot (indicated by having just the App Service name), which will copy all of the application settings to the staging slot.

    You could have also used the following CLI command:

    az webapp deployment slot create -g "<resource group>" -n "<app-service>" -s "staging" --configuration-source "<app-service>"

    Alternatively, you could have used the following PowerShell command:

    New-AzWebAppSlot -ResourceGroupName "<resource group>" -Name "<app-service>" -Slot "staging"
  3. Select the staging deployment slot and, from within the Configuration blade, change the value of both CURRENT_SLOT and ORIGINAL_SLOT to Staging rather than Production. Save and continue.

    Conceptually, there are some different configurations between the staging and production slots, which you could have also replicated with different code.

  4. From within VS Code, on the assumption that the out folder still remains from the previous exercise when you deployed the code to App Service, open the command palette either by going to View and then Command Palette or using the relevant shortcuts. In Windows, this is Ctrl + Shift + P by default.
  5. Start typing and then select Azure App Service: Deploy to Slot….
  6. When prompted, select your App Service resource, the new staging slot, browse to and select the out folder previously created, and confirm the deployment when the pop-up window appears requesting confirmation.
  7. Once the deployment completes, browse to the production slot URL for App Service (that is, https: //<app-service>.azurewebsites. net) and confirm that the production text is there. Now, do the same with the staging URL (that is, https: //<app-service>-staging.azurewebsites. net) and confirm that the staging text is there. Once confirmed, navigate back to the main/production URL so that you’re ready for the next step.

    This shows how you could test changes in the staging slot/app before pushing it to production via the staging URL. The documentation also explains how you can use a query string in a link to App Service, which users could use to opt into the staging/beta/preview app experience. Check out the Further Reading section of this chapter for the relevant link.

  8. From the main App Service (not the staging app) within the Azure portal, open the Deployment slots blade and notice that you can change the percentage of traffic that flows to each slot.

    This allows you to control the exposure of the staging slot before making the switch. Rather than using that right now, just click on Swap. Note that you can preview the changes that will be made, which will be the text changing for the ORIGINAL_SLOT application setting. Confirm this by clicking on Swap.

  9. Go back to the tab/window with the production site showing and periodically refresh the page. There should be no downtime. At some point, the Original slot text will change from Production to Staging, showing that the app that was originally in the staging slot was swapped with production and your changes are now live in the production app:
Figure 2.23: Text showing that the previous staging app is now the production app

Figure 2.23: Text showing that the previous staging app is now the production app

  1. When you’re done with this exercise, feel free to clean up your resources by deleting the resource group containing all the resources created in this chapter.

If you wanted to, you could revert the changes by swapping the slots again.

One final point to note is that although the default behavior is for all the slots of App Service to share the same App Service plan, this can be changed by changing the App Service plan in each slot individually.

With that final point, you have come to the end of our exploration of App Service. A lot of the concepts we’ve discovered here will help with the topics that will be covered throughout this book, as a lot of them will dive deeper or reference concepts we’ve already covered in some detail. If you can understand the concepts discussed in this chapter, you’ll already be ahead of the majority of people who pass the exam.

You have been reading a chapter from
Developing Solutions for Microsoft Azure AZ-204 Exam Guide - Second Edition
Published in: May 2024
Publisher: Packt
ISBN-13: 9781835085295
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image