Exercise 1 - Deployment of a sample custom website

Completed

In this exercise, you'll deploy a multipage ASP.NET website to a free tier Azure App Service on Microsoft Azure by using Visual Studio Code and its extensions.

Important

Make sure that all prerequisites from the previous unit are met before you start the exercise.

Task 1: Open and inspect the provided website code with Visual Studio Code

In this task, you’ll open the provided website code and inspect its CSS and HTML code. Additionally, you’ll find where the <HEAD></HEAD> and the <HEADER></HEADER> blocks of the HTML code are stored.

  1. Download the code for the sample Fabrikam Application website.

  2. Create a directory called MC4R-Clarity under your C:\ drive and then extract the project zip file to that path. The following folder structure should display when you expand the folder in your File Explorer navigation pane tree view.

    Screenshot of the folder structure for the directory.

  3. Open the Fabrikam directory under your C:\MC4R-Clarity directory with Visual Studio Code, for which you’ve already installed the required extensions and .NET SDK, as listed in the previous prerequisites section. To accomplish this task:

    1. Launch Visual Studio Code.

    2. Select the File menu.

    3. Select the Open Folder menu item.

      Screenshot of the Visual Studio Code file menu with Open Folder selected.

    4. Select C:\MC4R-Clarity\Fabrikam from the file browser and then select the Select Folder button.

      Screenshot of the folder selected with the Select Folder button.

    5. Select the Yes, I trust the authors button on the trust notification pop-up window.

      Screenshot of the Yes, I trust the authors button.

      Your Visual Studio Code screen should resemble the following screenshot.

      Screenshot of the Visual Studio code screen with areas labeled.

  4. From the Explorer pane of Visual Studio Code, expand the >Pages > >Shared sub directory and then select _Layout.cshtml. The <HEAD></HEAD> section should display, where you’ll change to integrate any website with Microsoft Clarity.

The <HEAD> section is the Document Metadata (Header) element of HTML web development language, and it contains machine-readable information (metadata) about the document, such as its title, scripts, and style sheets. It shouldn't be confused with the <HEADER> section, which is a sub section of the <BODY> section.

Screenshot of the Explorer pane in Visual Studio Code.

Task 2: Deploy the web application to Azure App Service

In this task, you'll deploy the sample application to Azure App Service by using the Visual Studio Code Azure App Service extension. To complete the deployment, follow these steps:

  1. From the Explorer window, find and then right-click the publish folder, and then select the Deploy to Web App menu item.

    Screenshot of the publish folder with the Deploy to Web App menu item selected.

    The Command Palette will open in the upper section of Visual Studio Code and will ask you to sign in to your Azure account.

    Screenshot of the Sign in to Azure option in the menu.

  2. After signing in, from the Command Palette, you'll be asked to select a subscription from a list of subscriptions. Select the subscription that you want to use for this exercise.

    Screenshot of the Select subscription menu from the Command Palette.

  3. The next prompt will ask you to select a web app. In the Select Web App menu, select Create new Web App... Advanced. If you select Create new Web App, you won't be able to specify in which Azure region that you want to create the service.

    Screenshot of the Create new Web App Advanced option.

  4. Enter a unique name for your web app (such as your username). This name will be part of the URL that you’ll use to access your website; therefore, it must be unique. The name can only contain letters, numbers, or hyphens.

    Screenshot of the unique name for the new web app.

  5. Select your choice of Azure resource group that will contain the app service.

    Screenshot of the Azure resource group selected.

  6. Select the runtime stack. Because your application is a .NET 6 application, as stated in the previous prerequisites section, select .NET 6(LTS).

    Screenshot of the runtime stack selected.

  7. Choose your operating system. For this application, in the Select an OS menu, select Windows.

    Screenshot of the operating system menu, showing Windows selected.

  8. Select an Azure region that will host the Azure App Service. Choose a region that’s geographically closest to you to have the maximum network performance.

    Screenshot of the Azure region menu.

  9. Select + Create new App Service plan to create the app service plan for your app hosting.

    Screenshot of the Create new App Service plan option in the menu.

  10. Choose a name for your Azure App Service plan, type it into the field, and then press the Enter key.

    Screenshot of the Azure App Service plan name.

  11. For this lab, you don't need a powerful hosting, so you can select Free (F1).

    Screenshot of the pricing tier menu with Free F1 selected.

  12. Skip the Create new Application Insights resource step by selecting Skip for now.

    Screenshot of the Skip for now button to skip the creation of a new Application Insights resource.

  13. When setup is complete, a notification will appear (resembling the one that’s shown in the following screenshot) in the lower-right corner of Visual Studio Code to monitor the process of your website's deployment.

    Screenshot of the setup process status notification.

  14. When the deployment has finished, you can select Browse Website to access your deployment. Don't forget to save the URL information of the website.

    Screenshot of the Browse Website button.

    Screenshot of the website U R L information to save.

  15. If another pop-up window appears (similar to the one shown in the following image), asking whether you'll deploy this project always to the same web app, select Yes. This setting will help make it easier for you to deploy when you’re completing the necessary changes for the Clarity integration on the web app.

    Screenshot of the always deploy the workspace to the same app message with Yes selected.

Congratulations, you’ve deployed your website. Make sure that you save the URL information of the website because you’ll need it in subsequent exercises.