You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 21, 2026. It is now read-only.
Copy file name to clipboardExpand all lines: Instructions/Labs/AZ400_M17_Monitoring_Application_Performance_with_Application_Insights.md
+82-40Lines changed: 82 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -77,55 +77,100 @@ In this task, you will use Azure DevOps Demo Generator to generate a new project
77
77
78
78
#### Task 2: Create Azure resources
79
79
80
-
In this task, you will create an Azure web app and an Azure SQL database by using the Azure portal.
80
+
In this task, you will create an Azure web app and an Azure SQL database by using the cloud shell in Azure portal.
81
81
82
82
> **Note**: This lab involves a deployment of the Parts Unlimited site to an Azure app service. To accommodate this requirement, you will need to spin up the necessary infrastructure.
83
83
84
84
1. From the lab computer, start a web browser, navigate to the [**Azure Portal**](https://portal.azure.com), and sign in with the user account that has the Owner role in the Azure subscription you will be using in this lab and has the role of the Global Administrator in the Azure AD tenant associated with this subscription.
85
-
1. In the Azure portal, click the icon consisting of three horizontal lines in the upper left corner of the page and, in the hub menu and click **+ Create a resource**.
86
-
1. On the **New* blade, in the search text box, type **Web App + SQL** and press the **Enter** key.
87
-
1. On the **Web App + SQL**, click **Create**.
88
-
1. On the **Web App + SQL** blade, specify the following settings:
85
+
1. In the Azure portal, in the toolbar, click the **Cloud Shell** icon located directly to the right of the search text box.
86
+
1. If prompted to select either **Bash** or **PowerShell**, select **Bash**.
87
+
>**Note**: If this is the first time you are starting **Cloud Shell** and you are presented with the **You have no storage mounted** message, select the subscription you are using in this lab, and select **Create storage**.
89
88
90
-
| Setting | Value |
91
-
| --- | --- |
92
-
| App name | any valid, globally unique DNS host name |
93
-
| Subscription | the name of the Azure subscription you are using in this lab |
94
-
| Resource group | the name of a new resource group **az400m17l01a-RG**|
89
+
1. From the **Bash** prompt, in the **Cloud Shell** pane, run the following command to create a resource group (replace the `<region>` placeholder with the name of the Azure region closest to you such as 'eastus').
90
+
91
+
```bash
92
+
RESOURCEGROUPNAME='az400m17l01a-RG'
93
+
LOCATION='<region>'
94
+
az group create --name $RESOURCEGROUPNAME --location $LOCATION
95
+
```
95
96
96
-
> **Note**: Record the value of the App Service web app. You will need it later in the lab.
97
+
1. To create a Windows App service plan by running the following command:
97
98
98
-
1. Click **App Service plan/Location**, on the **App Service plan** blade, click **+ Create new**.
99
-
1. On the **New App Service Plan** blade, specify the following settings and click **OK**:
99
+
```bash
100
+
SERVICEPLANNAME='az400l17-sp'
101
+
az appservice plan create --resource-group $RESOURCEGROUPNAME \
102
+
--name $SERVICEPLANNAME --sku B3
103
+
```
104
+
>**Note**: If the `az appservice plan create`command fails with an error message starting with `ModuleNotFoundError: No module named 'vsts_cd_manager'`, then run the following commands and then re-run the failed command.
100
105
101
-
| Setting | Value |
102
-
| --- | --- |
103
-
| App service plan |any valid name |
104
-
| Location| the name of the Azure region where you want to deploy resources you will be using in this lab |
105
-
| Pricing tier |**D1 Shared**|
106
+
```bash
107
+
az extension remove --name appservice-kube
108
+
az extension add --yes --source "https://aka.ms/appsvc/appservice_kube-latest-py2.py3-none-any.whl"
109
+
```
110
+
1. Create a web app with a unique name.
106
111
107
-
1. Back on the **Web App + SQL** blade, click **SQL Database** and **Create new Database**.
108
-
1. On the **SQL Database** blade, in the **Name** textbox, type **partsunlimited**.
109
-
1. On the **SQL Database** blade, click **Target server**.
110
-
1. On the **New server** blade, specify the following settings and click **Select** (leave all other settings with their default values):
112
+
```bash
113
+
WEBAPPNAME=partsunlimited$RANDOM$RANDOM
114
+
az webapp create --resource-group $RESOURCEGROUPNAME --plan $SERVICEPLANNAME --name $WEBAPPNAME
115
+
```
111
116
112
-
| Setting | Value |
113
-
| --- | --- |
114
-
| Server name | any valid, globally unique DNS host name |
115
-
| Server admin login |**sysadmin**|
116
-
| Password |**Pa55w.rd1234**|
117
-
| Location | the name of the Azure region that you chose for the App Service plan |
118
-
| Allow Azure services to access server | enabled |
117
+
>**Note**: Record the name of the web app. You will need it later in this lab.
119
118
120
-
1. Back on the **SQL Database** blade, click **Select**.
119
+
1. Now is the time to create an Application Insights instance.
121
120
122
-
> **Note**: By default, the template will generate an Application Insights resource and attach it to the app service.
121
+
```bash
122
+
az monitor app-insights component create --app $WEBAPPNAME \
123
+
--location $LOCATION \
124
+
--kind web --application-type web \
125
+
--resource-group $RESOURCEGROUPNAME
126
+
```
127
+
128
+
>**Note**: If you got prompted with 'The command requires the extension application-insights. Do you want to install it now?', type Y and press enter.
123
129
124
-
1. Back on the **Web App + SQL** blade, click the Application Insights entry.
125
-
1. On the **Application Insights** blade, with the **.NET** tab selected, in the **Collection level** section, select **Recommended**, on the **Application Insights** blade, in the **Profiler** section, select **On**, and click **Apply**.
126
-
1. Back on the **Web App + SQL** blade, click **Create**.
130
+
1. Let us connect the Application Insights to our web application.
131
+
132
+
```bash
133
+
az monitor app-insights component connect-webapp --app $WEBAPPNAME \
az sql db create --server $SERVERNAME --resource-group $RESOURCEGROUPNAME --name PartsUnlimited \
161
+
--service-objective S0
162
+
```
163
+
164
+
1. The web app you created needs the database connection string in its configuration, so run the following commands to prepare and add it to the app settings of the web app.
165
+
166
+
```bash
167
+
CONNSTRING=$(az sql db show-connection-string --name PartsUnlimited --server $SERVERNAME \
### Exercise 1: Monitor an Azure App Service web app by using Azure Application Insights
131
176
@@ -191,11 +236,6 @@ In this task, you will deploying a web app to Azure by using Azure DevOps pipeli
191
236
1. In the **Application settings** section, click **+ New application setting**.
192
237
1. On the **Add/Edit application setting** blade, in the **Name** textbox, type **Keys:ApplicationInsights:InstrumentationKey**, in the **Value** textbox, type the string of characters you copied into Clipboard and click **OK**.
193
238
194
-
> **Note**: As with the **Application Insights** key, we also need to configure the Azure SQL Database connection string expected by our application.
195
-
196
-
1. On the App Service web app **Configuration** blade, scroll down to the **Connection string** section and click **defaultConnection**.
197
-
1. On the **Add/Edit connection string** blade, in the **Name** textbox, replace **defaultConnection** with **DefaultConnectionString**, click **OK**, click **Save** to save the configuration settings, and, when prompted for confirmation, click **Continue**.
198
-
199
239
> **Note**: Changes to the application settings and connection strings trigger restart of the web app.
200
240
201
241
1. Switch back to the web browser window displaying the Azure DevOps portal, in the vertical navigational pane, select the **Pipelines**, and, in the **Pipelines** section, click the entry representing your most recently run build pipeline.
@@ -223,6 +263,8 @@ In this task, you will generate traffic targeting the App Service web app you de
223
263
1. On the **Application Insights** configuration blade, click the **View Application Insights data** link.
224
264
1. Review the resulting **Application Insights** blade displaying charts presenting different characteristics of the collected data, including the traffic you generated and failed requests you triggered earlier in this task.
225
265
266
+
> **Note**: If you didn't see anything right away, just waitfora few minutes and refresh the page until the logs start to show upin the overview section.
267
+
226
268
#### Task 3: Investigate application performance
227
269
228
270
In this task, you will use Application Insights to investigate performance of the App Service web app.
0 commit comments