Ask Learn Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This module requires a sandbox to complete. A sandbox gives you access to free resources. Your personal subscription will not be charged. The sandbox may only be used to complete training on Microsoft Learn. Use for any other reason is prohibited, and may result in permanent loss of access to the sandbox.
Microsoft provides this lab experience and related content for educational purposes. All presented information is owned by Microsoft and intended solely for learning about the covered products and services in this Microsoft Learn module.
In this exercise, you deploy a sample ASP.NET Core Web app from GitHub, which has the code required to generate trace output messages. Then, you use the Azure portal to enable app logging for the app.
In this task, you use Azure CLI to create an ASP.NET Web app using code from a GitHub repository. You also create a new storage account in the same region as the Web app, for log storage.
Let's set some variables, so we can use them throughout the rest of the exercise. Run the following commands in Azure Cloud Shell, replacing <your-local-Azure-region>, with the region closest to you from the following list.
The free sandbox allows you to create resources in a subset of the Azure global regions. Select a region from this list when you create resources:
gitRepo=https://github.com/MicrosoftDocs/mslearn-capture-application-logs-app-service
appName="contosofashions$RANDOM"
appPlan="contosofashionsAppPlan"
resourceGroup=[sandbox resource group name]
storageAccount=sa$appName
appLocation=<your-local-Azure-region>
Run the following commands to deploy the web app.
az appservice plan create --name $appPlan --resource-group $resourceGroup --location $appLocation --sku FREE
az webapp create --name $appName --resource-group $resourceGroup --plan $appPlan --deployment-source-url $gitRepo
The app can take several minutes to deploy.
Make a note of your app name, including the random number that was generated to uniquely identify your app. It should resemble something like: contosofashions13642.azurewebsites.net
.
Run the following command to create a storage account.
az storage account create -n $storageAccount -g $resourceGroup -l $appLocation --sku Standard_LRS
Wait for the command to complete, and then continue with this exercise.
In this task, you use the Azure portal to enable app logging for the file system and Azure Blob storage. Start by verifying that your Web app is running.
Sign in to the Azure portal using the same account used to activate the sandbox.
On the Azure portal menu, or from the Home page, select App Services. The App Services pane appears.
In the App Services list, select contosofashions<your-number>. The contosofashions<your-number> Web App menu appears.
On the Web App menu, in the Essentials section, copy the default domain and paste it in a new browser tab (For example, contosofashionsNNNNN.azurewebsites.net
). The home page for Contoso Fashions should appear.
Let's set up app logging.
On the left-hand menu for your Web App, scroll down to the Monitoring section and expand it if necessary. Select App Service logs. The App Service logs pane appears.
Under Application Logging (Filesystem), select On, and in the Level box dropdown list, select Error.
Under Application Logging (Blob), select On, and in the Level box dropdown list, select Verbose.
Select the 0 link under Storage Containers. The Storage accounts pane appears.
Note
If a notification Storage not configured appears, select that text, and complete the previous 3 steps.
In the Name list, select sacontosofashionsNNNN, where NNNN is the number you noted when you created your app. The Containers pane appears.
In the command bar, select Container. The New container pane appears.
In the Name box, enter appsrvplogs, and then select Create.
In the Containers pane, select appsrvplogs, and then choose Select. The App Service logs pane appears.
In the Retention Period (Days) box, enter 5.
In the command bar, select Save to update the log settings and close the logs pane.
Having an issue? We can help!
Please sign in to use this experience.
Sign in