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
Copy file name to clipboardExpand all lines: articles/traffic-manager/quickstart-create-traffic-manager-profile-cli.md
+30-47Lines changed: 30 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ ms.service: traffic-manager
8
8
ms.topic: quickstart
9
9
ms.tgt_pltfrm: na
10
10
ms.workload: infrastructure-services
11
-
ms.date: 04/19/2021
11
+
ms.date: 02/18/2023
12
12
ms.author: greglin
13
13
ms.custom: devx-track-azurecli, mode-api
14
14
#Customer intent: As an IT admin, I want to direct user traffic to ensure high availability of web applications.
@@ -45,19 +45,20 @@ The following example creates a resource group named *myResourceGroup* in the *e
45
45
46
46
Create a Traffic Manager profile using [az network traffic-manager profile create](/cli/azure/network/traffic-manager/profile#az-network-traffic-manager-profile-create) that directs user traffic based on endpoint priority.
47
47
48
-
In the following example, replace **<profile_name>** with a unique Traffic Manager profile name.
@@ -68,18 +69,17 @@ For this quickstart, you'll need two instances of a web application deployed in
68
69
### Create web app service plans
69
70
Create web app service plans using [az appservice plan create](/cli/azure/appservice/plan#az-appservice-plan-create) for the two instances of the web application that you will deploy in two different Azure regions.
70
71
71
-
In the following example, replace **<appspname_eastus>** and **<appspname_westeurope>** with a unique App Service Plan Name
72
72
73
73
```azurecli-interactive
74
74
75
75
az appservice plan create \
76
-
--name <appspname_eastus> \
76
+
--name myAppServicePlanEastUS \
77
77
--resource-group myResourceGroup \
78
78
--location eastus \
79
79
--sku S1
80
80
81
81
az appservice plan create \
82
-
--name <appspname_westeurope> \
82
+
--name myAppServicePlanWestEurope \
83
83
--resource-group myResourceGroup \
84
84
--location westeurope \
85
85
--sku S1
@@ -89,18 +89,19 @@ az appservice plan create \
89
89
### Create a web app in the app service plan
90
90
Create two instances the web application using [az webapp create](/cli/azure/webapp#az-webapp-create) in the App Service plans in the *East US* and *West Europe* Azure regions.
91
91
92
-
In the following example, replace **<app1name_eastus>** and **<app2name_westeurope>** with a unique App Name, and replace **<appspname_eastus>** and **<appspname_westeurope>** with the name used to create the App Service plans in the previous section.
93
-
94
92
```azurecli-interactive
95
93
94
+
mywebappeastus='myWebAppEastUS'$RANDOM
95
+
myWebAppWestEurope='myWebAppWestEurope'$RANDOM
96
+
96
97
az webapp create \
97
-
--name <app1name_eastus> \
98
-
--plan <appspname_eastus> \
98
+
--name $mywebappeastus \
99
+
--plan myAppServicePlanEastUS \
99
100
--resource-group myResourceGroup
100
101
101
102
az webapp create \
102
-
--name <app2name_westeurope> \
103
-
--plan <appspname_westeurope> \
103
+
--name $myWebAppWestEurope \
104
+
--plan myAppServicePlanWestEurope \
104
105
--resource-group myResourceGroup
105
106
106
107
```
@@ -113,59 +114,41 @@ Add the two Web Apps as Traffic Manager endpoints using [az network traffic-mana
113
114
114
115
When the primary endpoint is unavailable, traffic automatically routes to the failover endpoint.
115
116
116
-
In the following example, replace **<app1name_eastus>** and **<app2name_westeurope>** with the App Names created for each region in the previous section. Then replace **<profile_name>** with the profile name used in the previous section.
117
117
118
118
**East US endpoint**
119
119
120
120
```azurecli-interactive
121
121
122
-
az webapp show \
123
-
--name <app1name_eastus> \
124
-
--resource-group myResourceGroup \
125
-
--query id
126
-
127
-
```
128
-
129
-
Make note of ID displayed in output and use in the following command to add the endpoint:
130
-
131
-
```azurecli-interactive
122
+
App1ResourceId=$(az webapp show --name $mywebappeastus --resource-group myResourceGroup --query id --output tsv)
132
123
133
124
az network traffic-manager endpoint create \
134
-
--name <app1name_eastus> \
125
+
--name $mywebappeastus \
135
126
--resource-group myResourceGroup \
136
-
--profile-name <profile_name> \
127
+
--profile-name $mytrafficmanagerprofile \
137
128
--type azureEndpoints \
138
-
--target-resource-id <ID from az webapp show> \
129
+
--target-resource-id $App1ResourceId \
139
130
--priority 1 \
140
131
--endpoint-status Enabled
132
+
141
133
```
142
134
143
135
**West Europe endpoint**
144
136
145
137
```azurecli-interactive
146
138
147
-
az webapp show \
148
-
--name <app2name_westeurope> \
149
-
--resource-group myResourceGroup \
150
-
--query id
151
-
152
-
```
153
-
154
-
Make note of ID displayed in output and use in the following command to add the endpoint:
155
-
156
-
```azurecli-interactive
139
+
App2ResourceId=$(az webapp show --name $myWebAppWestEurope --resource-group myResourceGroup --query id --output tsv)
157
140
158
141
az network traffic-manager endpoint create \
159
-
--name <app2name_westeurope> \
142
+
--name $myWebAppWestEurope \
160
143
--resource-group myResourceGroup \
161
-
--profile-name <profile_name> \
144
+
--profile-name $mytrafficmanagerprofile \
162
145
--type azureEndpoints \
163
-
--target-resource-id <ID from az webapp show> \
146
+
--target-resource-id $App2ResourceId \
164
147
--priority 2 \
165
148
--endpoint-status Enabled
166
-
167
149
```
168
150
151
+
169
152
## Test your Traffic Manager profile
170
153
171
154
In this section, you'll check the domain name of your Traffic Manager profile. You'll also configure the primary endpoint to be unavailable. Finally, you get to see that the web app is still available. It's because Traffic Manager sends the traffic to the failover endpoint.
@@ -179,7 +162,7 @@ Determine the DNS name of the Traffic Manager profile using [az network traffic-
179
162
```azurecli-interactive
180
163
181
164
az network traffic-manager profile show \
182
-
--name <profile_name> \
165
+
--name $mytrafficmanagerprofile \
183
166
--resource-group myResourceGroup \
184
167
--query dnsConfig.fqdn
185
168
@@ -197,9 +180,9 @@ Copy the **RelativeDnsName** value. The DNS name of your Traffic Manager profile
0 commit comments