Skip to content

Commit b142721

Browse files
author
Hao Chen
committed
Merge branch 'clu' of github.com:Azure/azure-powershell into webapp-test
2 parents 21954cb + af9dfe7 commit b142721

File tree

3 files changed

+51
-50
lines changed

3 files changed

+51
-50
lines changed

clu-getstart.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, copy the flav
6363
(All of those are subject to change, contact yugangw or adxsdkdev for any questions)
6464

6565
### Quick introductions on cmdlets
66-
* Run commands using the ‘az’ prefix, cmdlet nouns, and cmdlet verbs, for example, `az environment get` maps to the cmdlet `Get-AzureRmEnvironment`
66+
* Run commands using the ‘az’ prefix, cmdlet nouns, and cmdlet verbs, for example, `az env get` maps to the cmdlet `Get-AzureRmEnvironment`
6767
* Cmdlet parameters use the double dash (--) so for example, getting a subscription with a particular name would be: `az subscription get –-SubscriptionName “name of subscription"`
6868
* To log in, 3 options
6969
* login interactively using device flow, this is the only option for msa account or any org-id with 2fa enforced, example: `az account add`
@@ -73,14 +73,14 @@ To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, copy the flav
7373
```az subscription get --SubscriptionName | az context set```
7474
* You can capture piped output using redirection to a file - the result will be the json serialization of the output object.
7575
```az subscription get > subscriptions.json```
76-
* You can use file input tu aparameter using '@' notation:
76+
* You can use file input to a parameter using '@' notation:
7777
```az command --param1 @file1.json```
7878
Reads input from file1.json and attempts to deserialize the .net object that is the Parameter type for ```param1```
7979
```az command --param1 @@file1.json```
8080
Does the same thing, but treats the input from ```file1.json``` as if it come from the pipeline, so that multiple objects will result in multiple invocations of ```ProcessRecord()``` for the target cmdlet.
8181
* There are some known issues with the current approach to sessions, which can cause session variables to not be propagated when running cmdlets in a pipeline, to work around this, set the 'CmdletSessionId' environment variable to a numeric value - all cmdlets running from the shell will use that session id, and sessions will work with pipelining
8282

83-
```set CmdletSessionId=1010 ```
83+
```set AzureProfile=1010 ```
8484

8585
### Testing Cmdlets
8686

@@ -119,7 +119,8 @@ Please set the environment variables for either Username/Password (no 2FA) or Se
119119

120120
- To implement an xunit bash scenario test you must
121121
- Add a ```[Collection("SampleCollection")]``` attribute to your test class
122-
- Add a field to your class of type ```ScenarioTestFixture``` and add a constructor that initializes it
122+
- Add a field to your class of type ```ScenarioTestFixture``` and add a constructor that initializes it.
123+
123124
```C#
124125
[Collection("SampleCollection")]
125126
public class SampleTestClass

examples/webapp-management/01-AppServicePlan.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ tier="Standard"
99
size="Medium"
1010
capacity=2
1111
skuName="S2"
12-
azure group create --name "$groupName" --location "$location"
12+
az group create --name "$groupName" --location "$location"
1313

1414
printf "\n1. Create a new app service plan %s " "$whpName"
15-
azure app service plan create -n "$whpName" -g "$groupName" -l "$location" --tier "$tier" --size "$size" --workers "$capacity"
15+
az app service plan create -n "$whpName" -g "$groupName" -l "$location" --tier "$tier" --size "$size" --workers "$capacity"
1616

1717
printf "\n2. Get information about the app service plan : %s.\n" "$whpName"
18-
whpInfo=`azure app service plan get --name $whpName --group $groupName`
18+
whpInfo=`az app service plan get --name $whpName --group $groupName`
1919

2020
printf "\nValidating app service plan name: %s\n" "$whpName"
2121
[ $(echo $whpInfo | jq '.name' --raw-output) == "$whpName" ]
@@ -28,7 +28,7 @@ printf "\n3. Set the appservice plan: %s " "$whpName"
2828
newTier="Shared"
2929
newCapacity=0
3030
newSize="Medium"
31-
setPlanInfo=`azure app service plan set -n $whpName -g $groupName --tier $newTier --workers --workers $newCapacity --size $newSize`
31+
setPlanInfo=`az app service plan set -n $whpName -g $groupName --tier $newTier --workers --workers $newCapacity --size $newSize`
3232
[ $(echo $setPlanInfo | jq '.name' --raw-output) == "$whpName" ]
3333
[ $(echo $setPlanInfo | jq '.sku.tier' --raw-output) == "$newTier" ]
3434
[ $(echo $setPlanInfo | jq '.sku.capacity' --raw-output) -eq $newCapacity ]
@@ -38,32 +38,32 @@ setPlanInfo=`azure app service plan set -n $whpName -g $groupName --tier $newTie
3838
whpName2=`randomName testplan`
3939
printf "\n4. Creating a new app service plan: %s" "$whpName2"
4040
location2="East US"
41-
azure app service plan create -n "$whpName2" -g "$groupName" -l "$location2" --tier "$tier" --size "$size" --workers "$capacity"
41+
az app service plan create -n "$whpName2" -g "$groupName" -l "$location2" --tier "$tier" --size "$size" --workers "$capacity"
4242

4343
printf "\n5. Get All app service plans by name: %s" "$whpName2"
44-
whpInfo2=`azure app service plan get --name $whpName2`
44+
whpInfo2=`az app service plan get --name $whpName2`
4545
[ $(echo $whpInfo | jq '.name' --raw-output) == "$whpName2" ]
4646
[ $(echo $whpInfo | jq '.location' --raw-output) == "$location2" ]
4747
[ $(echo $whpInfo | jq '.sku.tier' --raw-output) == "$tier" ]
4848
[ $(echo $whpInfo | jq '.sku.name' --raw-output) == "$skuName" ]
4949
[ $(echo $whpInfo | jq '.sku.capacity' --raw-output) -eq $capacity ]
5050

5151
printf "\n6. Get All app service plans by resource group: %s" "$groupName"
52-
plansByGroup=`azure app service plan get --group $groupName`
52+
plansByGroup=`az app service plan get --group $groupName`
5353
[ $plansByGroup == *"$whpName"* ]
5454
[ $plansByGroup == *"$whpName2"* ]
5555

5656
printf "\n7. Get All app service plans by location: %s" "$location2"
57-
plansByLocation=`azure app service plan get -l $location2`
57+
plansByLocation=`az app service plan get -l $location2`
5858
[ $plansByLocation == *"$whpName2"* ]
5959

6060
printf "\n8. Get All app service plans in a subscription."
61-
plansInSubscription=`azure app service plan get`
61+
plansInSubscription=`az app service plan get`
6262
[ $plansInSubscription == *"$whpName"* ]
6363
[ $plansInSubscription == *"$whpName2"* ]
6464

6565
printf "\n9. Remove app service plan: %s." "$whpName"
66-
azure app service plan remove -n $whpName -g $groupName
66+
az app service plan remove -n $whpName -g $groupName
6767

6868
printf "\n10. Remove app service plan: %s." "$whpName2"
69-
azure app service plan remove -n $whpName2 -g $groupName
69+
az app service plan remove -n $whpName2 -g $groupName

examples/webapp-management/03-WebApp.sh

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
printf "\n=== Managing Web Apps in Azure ===\n"
33

44
printf "\nSetup: Creating a new resource group: %s at location: %s.\n" "$groupName" "$location"
5-
azure group create --name "$groupName" --location "$location"
5+
az group create --name "$groupName" --location "$location"
66

77
appName1=`randomName testweb`
88
appName2=`randomName testweb`
@@ -19,56 +19,56 @@ tier2="Standard"
1919
tier3="Premium"
2020

2121
printf "\nSetup: Creating a new app service plan: %s under resource group: %s.\n" "$planName1" "$groupName"
22-
serverFarm=`azure app service plan create -n "$planName1" -g "$groupName" -l "$location" --tier "$tier1"`
22+
serverFarm=`az app service plan create -n "$planName1" -g "$groupName" -l "$location" --tier "$tier1"`
2323

2424
printf "\n1: Creating a new webapp: %s under resource group: %s.\n" "$appName1" "$groupName"
25-
actual1=`azure webapp create -g "$groupName" -l "$location" -n "$appName1" --plan "$planName1"`
25+
actual1=`az webapp create -g "$groupName" -l "$location" -n "$appName1" --plan "$planName1"`
2626

2727
printf "\n2: Getting info about webapp: %s.\n" "$appName1"
28-
result=`azure webapp get -g "$groupName" -n "$appName1"`
28+
result=`az webapp get -g "$groupName" -n "$appName1"`
2929
[ $(echo $result | jq '.Name' --raw-output) == "$appName1" ]
3030
[ $(echo $result | jq '.serverFarmId' --raw-output) == $(echo $serverFarm | jq '.id' --raw-output) ]
3131

3232
printf "\n3: Creating a new webapp: %s under resource group: %s.\n" "$appName2" "$groupName"
33-
actual2=`azure webapp create -g "$groupName" -l "$location" -n "$appName2" --plan "$planName1"`
33+
actual2=`az webapp create -g "$groupName" -l "$location" -n "$appName2" --plan "$planName1"`
3434
[ $(echo $actual2 | jq '.name' --raw-output) == "$appName2" ]
3535
[ $(echo $actual2 | jq '."properties.serverFarmId"' --raw-output) == $(echo $serverFarm | jq '.id' --raw-output) ]
3636

3737
printf "\n4: Get WebApp by ResourceGroup: %s.\n" "$groupName"
38-
count=`azure webapp get -g "$groupName"`
38+
count=`az webapp get -g "$groupName"`
3939
[ $(echo $count | jq -s '. | length') -eq 2 ]
4040

4141
printf "\n5: Get WebApp by App Plan :%s.\n" "$planName1"
42-
count=`azure webapp get --plan "$serverFarm"`
42+
count=`az webapp get --plan "$serverFarm"`
4343
[ $(echo $count | jq -s '. | length') -eq 2 ]
4444

4545
printf "\n6: Get WebApp by location :%s.\n" "$location"
46-
count=`azure webapp get -l "$location"`
46+
count=`az webapp get -l "$location"`
4747
[ $(echo $count | jq -s '. | length') -ge 2 ]
4848

4949
printf "\n7: Get WebApp under the current subscription.\n"
50-
count=`azure webapp get`
50+
count=`az webapp get`
5151
[ $(echo $count | jq -s '. | length') -ge 2 ]
5252

5353
printf "\n8: Get WebApp metrics ['CPU', 'Requests'] for webapp: %s" "$appName1"
5454
start=`date +"%Y-%m-%dT%H:%M:%SZ"`
55-
metricsInfo=`azure webapp metrics get -g "$groupName" -n "$appName1" --starttime "$start" --granularity PT1M --metrics "[\"CPU\", \"Requests\"]"`
55+
metricsInfo=`az webapp metrics get -g "$groupName" -n "$appName1" --starttime "$start" --granularity PT1M --metrics "[\"CPU\", \"Requests\"]"`
5656
[ $(echo $metricsInfo | jq -s '. | length') -eq 2 ]
5757
[ $(echo $metricsInfo | jq -sr '. [0].name.value') == "Requests" ] || [ $(echo $metricsInfo | jq -sr '. [0].name.value') == "CPU" ]
5858
[ $(echo $metricsInfo | jq -sr '. [1].name.value') == "CPU" ] || [ $(echo $metricsInfo | jq -sr '. [1].name.value') == "Requests" ]
5959

6060
printf "\n9: Creating a new app service plan: %s under resource group: %s.\n" "$planName2" "$groupName"
61-
serverFarm2=`azure app service plan create -n "$planName2" -g "$groupName" -l "$location" --tier "$tier2"`
61+
serverFarm2=`az app service plan create -n "$planName2" -g "$groupName" -l "$location" --tier "$tier2"`
6262

6363
printf "\n10: Change webapp: %s to new service plan: %s\n" "$appName2" "$planName2"
64-
changePlan=`azure webapp set -g "$groupName" -n $appName2 --plan $planName2`
64+
changePlan=`az webapp set -g "$groupName" -n $appName2 --plan $planName2`
6565
[ $(echo $changePlan | jq '.name' --raw-output) == "$appName2" ]
6666
[ $(echo $changePlan | jq '."properties.serverFarmId"' --raw-output) == $(echo $serverFarm2 | jq '.id' --raw-output) ]
6767

6868
printf "\n11: Set config properties 'httpLoggingEnabled' & 'requestTracingEnabled' of the webapp: %s to true.\n" "$appName2"
6969
changePlan=`echo $changePlan | jq '."properties.siteConfig"."properties.httpLoggingEnabled"'=true`
7070
changePlan=`echo $changePlan | jq '."properties.siteConfig"."properties.requestTracingEnabled"'=true`
71-
changePlan=`echo $changePlan | azure webapp set`
71+
changePlan=`echo $changePlan | az webapp set`
7272
[ $(echo $changePlan | jq '.name' --raw-output) == "$appName2" ]
7373
[ $(echo $changePlan | jq '."properties.serverFarmId"' --raw-output) == $(echo $serverFarm2 | jq '.id' --raw-output) ]
7474
[ $(echo $changePlan | jq '."properties.siteConfig"."properties.httpLoggingEnabled"' --raw-output) == true ]
@@ -78,7 +78,7 @@ printf "\n12: Set appsettings and connectionstrings of the webapp: %s.\n" "$appN
7878
appsettings="{\"setting1\":\"valueA\",\"setting2\":\"valueB\"}"
7979
constr="{ \"connstring1\": { \"Type\": \"MySql\", \"Value\": \"string value 1\" }, \"connstring2\": { \"Type\": \"SqlAzure\", \"Value\": \"string value 2\" } }"
8080

81-
setconn=`azure webapp set -g "$groupName" -n "$appName2" --appsettings "$appsettings" --connectionstrings "$constr"`
81+
setconn=`az webapp set -g "$groupName" -n "$appName2" --appsettings "$appsettings" --connectionstrings "$constr"`
8282
[ $(echo $setconn | jq '.name' --raw-output) == "$appName2" ]
8383
[ $(echo $setconn | jq '."properties.siteConfig"."properties.appSettings" | length') -eq 2 ]
8484
[ $(echo $setconn | jq '."properties.siteConfig"."properties.connectionStrings" | length') -eq 2 ]
@@ -98,89 +98,89 @@ conexn=`echo $setconn | jq -r '."properties.siteConfig"."properties.connectionSt
9898
[ $(echo $conexn | jq -r '.[1].type') == "SQLAzure" ]
9999

100100
printf "\n13: Stop the webapp: %s.\n" "$appName2"
101-
stop=`azure webapp stop -g "$groupName" -n "$appName2"`
101+
stop=`az webapp stop -g "$groupName" -n "$appName2"`
102102
[ $(echo $stop | jq '.name' --raw-output) == "$appName2" ]
103103
[ $(echo $stop | jq '."properties.state"' --raw-output) == "Stopped" ]
104104

105105
printf "\n14: Start the webapp: %s.\n" "$appName2"
106-
start=`azure webapp start -g "$groupName" -n "$appName2"`
106+
start=`az webapp start -g "$groupName" -n "$appName2"`
107107
[ $(echo $start | jq '.name' --raw-output) == "$appName2" ]
108108
[ $(echo $start | jq '."properties.state"' --raw-output) == "Running" ]
109109

110110
printf "\n15: Stop the webapp: %s again.\n" "$appName2"
111-
stop=`azure webapp stop -g "$groupName" -n "$appName2"`
111+
stop=`az webapp stop -g "$groupName" -n "$appName2"`
112112
[ $(echo $stop | jq '.name' --raw-output) == "$appName2" ]
113113
[ $(echo $stop | jq '."properties.state"' --raw-output) == "Stopped" ]
114114

115115
printf "\n16: Start the webapp: %s again.\n" "$appName2"
116-
start=`azure webapp start -g "$groupName" -n "$appName2"`
116+
start=`az webapp start -g "$groupName" -n "$appName2"`
117117
[ $(echo $start | jq '.name' --raw-output) == "$appName2" ]
118118
[ $(echo $start | jq '."properties.state"' --raw-output) == "Running" ]
119119

120120
printf "\n17: Restart the webapp: %s.\n" "$appName2"
121-
start=`azure webapp restart -g "$groupName" -n "$appName2"`
121+
start=`az webapp restart -g "$groupName" -n "$appName2"`
122122
[ $(echo $start | jq '.name' --raw-output) == "$appName2" ]
123123
[ $(echo $start | jq '."properties.state"' --raw-output) == "Running" ]
124124

125125
printf "\n18: Creating a new app service plan: %s under resource group: %s with Premium tier.\n" "$planName3" "$groupName"
126-
serverFarm3=`azure app service plan create -n "$planName3" -g "$groupName" -l "$location" --tier "$tier3"`
126+
serverFarm3=`az app service plan create -n "$planName3" -g "$groupName" -l "$location" --tier "$tier3"`
127127
[ $(echo $serverFarm3 | jq '.name' --raw-output) == "$planName3" ]
128128

129129
printf "\n19: Changing plan: %s to Premium tier.\n" "$planName1"
130-
plan1set=`azure app service plan set -n "$planName1" -g "$groupName" --tier "$tier3"`
130+
plan1set=`az app service plan set -n "$planName1" -g "$groupName" --tier "$tier3"`
131131
[ $(echo $plan1set | jq '.sku.tier' --raw-output) == "$tier3" ]
132132

133133
printf "\n20: Cloning a new webapp: %s from an existing webapp: %s.\n" "$appName3" "$appName1"
134-
clone=`azure webapp create -g "$groupName" -l "$location" -n "$appName3" --plan "$planName3" --sourcewebapp "$actual1"`
134+
clone=`az webapp create -g "$groupName" -l "$location" -n "$appName3" --plan "$planName3" --sourcewebapp "$actual1"`
135135
[ $(echo $clone | jq '.name' --raw-output) == "$appName3" ]
136136

137137
printf "\n21: Get the newly created webapp: %s.\n" "$appName3"
138-
result3=`azure webapp get -g "$groupName" -n "$appName3"`
138+
result3=`az webapp get -g "$groupName" -n "$appName3"`
139139
[ $(echo $result3 | jq '.name' --raw-output) == "$appName3" ]
140140

141141
#Need to ask the webapp team about the creation of traffic manager profile
142142
#printf "\n22: Creating a new app service plan: %s under resource group: %s with Premium tier.\n" "$planName4" "$groupName"
143-
#serverFarm4=`azure app service plan create -n "$planName4" -g "$groupName" -l "$location" --tier "$tier3"`
143+
#serverFarm4=`az app service plan create -n "$planName4" -g "$groupName" -l "$location" --tier "$tier3"`
144144
#[ $(echo $serverFarm4 | jq '.name' --raw-output) == "$planName4" ]
145145

146146
#profileName=`randomName profile`
147147
#printf "\n23: Cloning a new webapp: %s from an existing webapp: %s with traffic manager profile: %s.\n" "$appName4" "$appName3" "$profileName"
148-
#cloneTraffic=`azure webapp create -g "$groupName" -l "$location" -n "$appName4" --plan "$planName4" --sourcewebapp "$clone" --trafficmanagerprofilename "$profileName"`
148+
#cloneTraffic=`az webapp create -g "$groupName" -l "$location" -n "$appName4" --plan "$planName4" --sourcewebapp "$clone" --trafficmanagerprofilename "$profileName"`
149149
#[ $(echo $cloneTraffic | jq '.name' --raw-output) == "$appName4" ]
150150

151151
#printf "\n24: Get the newly created webapp: %s.\n" "$appName4"
152-
#result4=`azure webapp get -g "$groupName" -n "$appName4"`
152+
#result4=`az webapp get -g "$groupName" -n "$appName4"`
153153
#[ $(echo $result4 | jq '.name' --raw-output) == "$appName4" ]
154154

155155
filename=`randomName pf`
156156
filename+=".xml"
157157
printf "\n25: Get the publish profile for webapp: %s and save it to %s file\n." "$appName3" "$filename"
158-
pubprof=`azure webapp profile get -g "$groupName" -n "$appName3" --outputfile "$filename"`
158+
pubprof=`az webapp profile get -g "$groupName" -n "$appName3" --outputfile "$filename"`
159159
[ -e "$filename" ]
160160
[ -s "$filename" ]
161161

162162
printf "\n26: Reset the publish profile for webapp: %s.\n" "$appName3"
163-
azure webapp profile reset -g "$groupName" -n "$appName3"
163+
az webapp profile reset -g "$groupName" -n "$appName3"
164164

165165
filename2=`randomName pf`
166166
filename2+=".xml"
167167
printf "\n27: Get the publish profile for webapp: %s after resetting and save it to %s file\n." "$appName3" "$filename2"
168-
pubprof2=`azure webapp profile get -g "$groupName" -n "$appName3" --outputfile "$filename2"`
168+
pubprof2=`az webapp profile get -g "$groupName" -n "$appName3" --outputfile "$filename2"`
169169
[ -e "$filename2" ]
170170
[ -s "$filename2" ]
171171

172172
filename3=`randomName pf`
173173
filename3+=".xml"
174174
printf "\n28: Get the publish profile for webapp: %s in format FileZilla3 and save it to %s file\n." "$appName3" "$filename3"
175-
azure webapp profile get -g "$groupName" -n "$appName3" --outputfile "$filename3" --format "FileZilla3"
175+
az webapp profile get -g "$groupName" -n "$appName3" --outputfile "$filename3" --format "FileZilla3"
176176
[ -e "$filename3" ]
177177
[ -s "$filename3" ]
178178

179179
printf "\n29:Remove created webapps: %s, %s, %s, %s.\n" "$appName1" "$appName2" "$appName3" "$appName4"
180-
azure webapp remove -g "$groupName" -n "$appName1" -f
181-
azure webapp remove -g "$groupName" -n "$appName2" -f
182-
azure webapp remove -g "$groupName" -n "$appName3" -f
183-
#azure webapp remove -g "$groupName" -n "$appName4" -f
180+
az webapp remove -g "$groupName" -n "$appName1" -f
181+
az webapp remove -g "$groupName" -n "$appName2" -f
182+
az webapp remove -g "$groupName" -n "$appName3" -f
183+
#az webapp remove -g "$groupName" -n "$appName4" -f
184184

185185
printf "\n30:Remove the resource group: %s.\n" "$groupName"
186-
deleterg=`azure group remove -n "$groupName" --force`
186+
deleterg=`az group remove -n "$groupName" --force`

0 commit comments

Comments
 (0)