Mastering Web App Creation: Deploying Projects from GitHub to Azure Deployment Slots - A Comprehensive Guide
In the ever-evolving landscape of cloud computing, Microsoft Azure stands out as a robust platform offering a wide array of services for developers and businesses. Among its many offerings, Azure Web Apps provide a scalable and efficient solution for hosting web applications. In this guide, we'll explore how to create a Web App using Azure CLI and set up a deployment slot for seamless updates and rollbacks.
Part 1: Creating a Web App Using Azure CLI
If you haven't already installed Azure CLI, you can do so by following the instructions provided on the official Azure documentation: Install Azure CLI.
Step 2: Log in to Azure
Open your PowerShell terminal or command prompt and log in to your Azure account using the following command:
Follow the on-screen instructions to complete the authentication process.
Step 3: Create a Resource Group
Resource groups provide a logical container for grouping Azure resources. Let's create a resource group for our Web App:
Step 4: Create a Web App Service Plan
Now, let's create a Web App Service Plan within the resource group we just created:
Step 5: Create a Web App
Next step, let's also create a Web App within the resource group we just created:
Step 6: Verify Web App Creation
Once the command completes execution, navigate to the Azure portal or run the following command to verify that the Web App has been created successfully. As highlighted below, the "defaultHostName" has been created.
Step 7: Deployment from GitHub
Now lets deploy our project on GitHub repository to our newly created Web App domain on Azure by executing the command below:
Upon navigating to our Web App in the Azure portal and launching the Default domain, the deployed project will be accessible via the Default domain, as demonstrated below
Step 8: Creating a Deployment Slot and Swapping Back
Using Azure Portal:
Navigate to Azure Web App: Navigate to the Web App you want to work with.
Access Deployment Slots: From the left-hand menu, under the "Settings" section, select "Deployment slots" then click on "Upgrade".
- Select the plan based on requirements.
- Create a New Slot: Click on the "Add Slot" button to create a new deployment slot. Provide a name for the slot (e.g., "staging") and configure any additional settings as needed.
- Initiate Swap Operation: Select the "Swap" tab.
- Configure Swap Options: Choose the source and destination slots for the swap operation. Typically, the staging slot will be selected as the Source, and the production slot will be the Target. Review any additional settings or options before proceeding.
Execute Swap: Click on the "Swap" button to initiate the swap operation. Confirm any prompts or warnings if necessary.
Monitor Swap Progress: Azure will begin swapping the slots, deploying the changes from the staging slot to the production slot. You can monitor the progress of the swap operation from the Azure portal.
Verify Changes: Once the swap is complete, verify that your changes are successfully deployed to the production slot. You can access your Web App's URL to ensure that the updated version is live and functioning as expected.
Review Swap Results: After the swap is finished, review the results to ensure that the operation completed successfully without any errors or issues. Check application logs and monitoring metrics if needed.
Clean Up (Optional): If you no longer need the staging slot or want to make further changes, you can manage deployment slots from the Azure portal, including deleting slots or creating additional slots as required.
Conclusion:
In this comprehensive guide, we've delved into the intricacies of deploying web applications on Azure, beginning with the creation of a Web App using Azure CLI and subsequently setting up a deployment slot for seamless testing and deployment. Leveraging Azure CLI, developers can efficiently manage resources and streamline deployment processes, whether through command-line operations or intuitive GUI interactions via the Azure portal. Deployment slots emerge as a pivotal feature, facilitating risk-free testing in staging environments before rolling out changes to production. By following the outlined steps, developers can harness Azure's robust capabilities to build, deploy, and manage web applications effectively, fostering a culture of continuous integration and deployment (CI/CD) to enhance efficiency and reliability in development workflows. As technology evolves, Azure remains a dependable platform, empowering developers to focus on innovation while Azure handles infrastructure management.
Subscribe to my newsletter
Read articles from Olamide Abe directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Olamide Abe
Olamide Abe
Tech enthusiast with a focus on cloud solutions. Proficient in Microsoft Azure, AWS and GCP, specializing in deploying and managing cloud resources, orchestrating CI/CD pipelines, and integrating DevOps best practices for seamless application delivery. Keen on optimizing infrastructures for scalability and performance.