Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

Commit 65762be

Browse files
authored
Merge pull request #137 from yashints/patch-2
M17:Simplifying lab instructions
2 parents d307ed5 + 5a10e06 commit 65762be

1 file changed

Lines changed: 82 additions & 40 deletions

File tree

Instructions/Labs/AZ400_M17_Monitoring_Application_Performance_with_Application_Insights.md

Lines changed: 82 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -77,55 +77,100 @@ In this task, you will use Azure DevOps Demo Generator to generate a new project
7777

7878
#### Task 2: Create Azure resources
7979

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.
8181

8282
> **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.
8383
8484
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**.
8988
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+
```
9596

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:
9798

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.
100105

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.
106111

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+
```
111116

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.
119118

120-
1. Back on the **SQL Database** blade, click **Select**.
119+
1. Now is the time to create an Application Insights instance.
121120

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.
123129

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 \
134+
--resource-group $RESOURCEGROUPNAME --web-app $WEBAPPNAME
135+
```
127136

128-
> **Note**: Wait for the process to complete. This should take about 2 minutes.
137+
1. Next, create an Azure SQL Server.
138+
139+
```bash
140+
USERNAME="Student"
141+
SQLSERVERPASSWORD="Pa55w.rd1234"
142+
SERVERNAME="partsunlimitedserver$RANDOM"
143+
144+
az sql server create --name $SERVERNAME --resource-group $RESOURCEGROUPNAME \
145+
--location $LOCATION --admin-user $USERNAME --admin-password $SQLSERVERPASSWORD
146+
```
147+
148+
1. The web app needs to be able to access the SQL server, so we need to allow access to Azure resources in the SQL Server firewall rules.
149+
150+
```bash
151+
STARTIP="0.0.0.0"
152+
ENDIP="0.0.0.0"
153+
az sql server firewall-rule create --server $SERVERNAME --resource-group $RESOURCEGROUPNAME \
154+
--name AllowAzureResources --start-ip-address $STARTIP --end-ip-address $ENDIP
155+
```
156+
157+
1. Now create a database within that server.
158+
159+
```bash
160+
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 \
168+
--client ado.net --output tsv)
169+
CONNSTRING=${CONNSTRING//<username>/$USERNAME}
170+
CONNSTRING=${CONNSTRING//<password>/$SQLSERVERPASSWORD}
171+
az webapp config connection-string set --name $WEBAPPNAME --resource-group $RESOURCEGROUPNAME \
172+
-t SQLAzure --settings "DefaultConnectionString=$CONNSTRING"
173+
```
129174

130175
### Exercise 1: Monitor an Azure App Service web app by using Azure Application Insights
131176

@@ -191,11 +236,6 @@ In this task, you will deploying a web app to Azure by using Azure DevOps pipeli
191236
1. In the **Application settings** section, click **+ New application setting**.
192237
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**.
193238
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-
199239
> **Note**: Changes to the application settings and connection strings trigger restart of the web app.
200240
201241
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
223263
1. On the **Application Insights** configuration blade, click the **View Application Insights data** link.
224264
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.
225265
266+
> **Note**: If you didn't see anything right away, just wait for a few minutes and refresh the page until the logs start to show up in the overview section.
267+
226268
#### Task 3: Investigate application performance
227269

228270
In this task, you will use Application Insights to investigate performance of the App Service web app.

0 commit comments

Comments
 (0)