Skip to content

Commit 5887150

Browse files
committed
Merge pull request #1 from Azure/clu
Clu branch update
2 parents d1cb437 + 364a997 commit 5887150

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+806
-903
lines changed

clu-getstart.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
### Prerequsites
44

5-
Visual Studio 2015 RTM with ASP.NET. For details, check out the [installation doc](http://docs.asp.net/en/latest/getting-started/installing-on-windows.html).
5+
* Visual Studio 2015 RTM with ASP.NET. For details, check out the [installation doc](http://docs.asp.net/en/latest/getting-started/installing-on-windows.html).
66

77
Note, after done, run `dnvm list` command to check the 'coreclr' runtime is installed with right version of `1.0.0-rc1-final`. If not, run `dnvm install 1.0.0-rc1-final -r coreclr -a x64 -p`. Remember always use `-p` flag, so the selection can persist.
88

9+
* Get the latest dotnet from "https://azureclu.blob.core.windows.net/tools/dotnet-win-x64.latest.zip", unzip, then add its bin folder to the PATH
10+
911
### Project Artifacts
1012

1113
CLUPackages require some additional files to direct generation of indexing, and to provide shortcuts when files are installed. These files can be copied from the Profile project and updated for each package.

examples/resource-management/03-Deployments.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName"
66
azure group create --name "$groupName" --location "$location"
77

88
printf "\n2. Test template with dynamic parameters\n"
9-
azure group deployment test -g "$groupName" --templatefile $BASEDIR/sampleTemplate.json --siteName "$resourceName" --hostingPlanName "$resourceName" --siteLocation "$location" --sku "Standard" --workerSize "0"
9+
azure group deployment test -g "$groupName" --templatefile $BASEDIR/sampleTemplate.json --siteName "$resourceName" --hostingPlanName "$resourceName" --siteLocation "$location" --workerSize "0"
1010

1111
printf "\n3. Test template with JSON parameter object\n"
12-
azure group deployment test -g "$groupName" --templatefile $BASEDIR/sampleTemplate.json --templateparameterobject "{\"siteName\":\"$resourceName\",\"hostingPlanName\":\"$resourceName\",\"siteLocation\":\"$location\",\"sku\":\"Standard\",\"workerSize\": 0 }"
12+
azure group deployment test -g "$groupName" --templatefile $BASEDIR/sampleTemplate.json --templateparameterobject "{\"siteName\":\"$resourceName\",\"hostingPlanName\":\"$resourceName\",\"siteLocation\":\"$location\",\"workerSize\": 0 }"
1313

1414
printf "\n4. Provisioning Deployment\n"
1515
deploymentInfo=`azure group deployment create --Name "$resourceName" --ResourceGroupName "$groupName" --TemplateFile $BASEDIR/sampleTemplate.json --TemplateParameterFile $BASEDIR/sampleTemplateParams.json`

examples/resource-management/04-RoleAssignments.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ azure role assignment create --ObjectId "$userId" --RoleDefinitionId "$roleDefin
2121

2222
printf "\n3. Delete last created Role Assignment.\n"
2323
assignments=$(azure role assignment get)
24-
assignmentId=$(echo $assignments | cat | jq '.[-1].ObjectId' -s --raw-output)
24+
assignmentId=$(echo $assignments | cat | jq '.[-1:][0].ObjectId' -s --raw-output)
25+
echo "Deleting assignment: $assignmentId"
2526
azure role assignment remove --ObjectId "$assignmentId" --Scope "$scope" --RoleDefinitionId "$roleDefinitionId" -f
2627
export MSYS_NO_PATHCONV=

examples/resource-management/sampleTemplate.json

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
2+
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
33
"contentVersion": "1.0.0.0",
44
"parameters": {
55
"siteName": {
@@ -11,16 +11,6 @@
1111
"siteLocation": {
1212
"type": "string"
1313
},
14-
"sku": {
15-
"type": "string",
16-
"allowedValues": [
17-
"Free",
18-
"Shared",
19-
"Basic",
20-
"Standard"
21-
],
22-
"defaultValue": "Free"
23-
},
2414
"workerSize": {
2515
"type": "int",
2616
"allowedValues": [
@@ -33,13 +23,17 @@
3323
},
3424
"resources": [
3525
{
36-
"apiVersion": "2014-04-01",
26+
"apiVersion": "2015-08-01",
3727
"name": "[parameters('hostingPlanName')]",
3828
"type": "Microsoft.Web/serverfarms",
3929
"location": "[parameters('siteLocation')]",
30+
"sku": {
31+
"name": "S1",
32+
"tier": "Standard",
33+
"capacity": 1
34+
},
4035
"properties": {
4136
"name": "[parameters('hostingPlanName')]",
42-
"sku": "[parameters('sku')]",
4337
"workerSize": "[parameters('workerSize')]",
4438
"numberOfWorkers": 1
4539
}

examples/resource-management/sampleTemplateParams.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
"siteLocation": {
99
"value": "West US"
1010
},
11-
"sku": {
12-
"value": "Standard"
13-
},
1411
"workerSize": {
1512
"value": 0
1613
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
set -e
3+
printf "\n=== Managing App Service Plans in Azure ===\n"
4+
5+
#setup
6+
printf "\nSetup: Creating a new resource group: %s at location: %s.\n" "$groupName" "$location"
7+
export whpName=`randomName testplan`
8+
tier="Standard"
9+
size="Medium"
10+
capacity=2
11+
skuName="S2"
12+
azure group create --name "$groupName" --location "$location"
13+
14+
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"
16+
17+
printf "\n2. Get information about the app service plan : %s.\n" "$whpName"
18+
whpInfo=`azure app service plan get --name $whpName --group $groupName`
19+
20+
printf "\nValidating app service plan name: %s\n" "$whpName"
21+
[ $(echo $whpInfo | jq '.name' --raw-output) == "$whpName" ]
22+
[ $(echo $whpInfo | jq '.location' --raw-output) == "West US" ]
23+
[ $(echo $whpInfo | jq '.sku.tier' --raw-output) == "$tier" ]
24+
[ $(echo $whpInfo | jq '.sku.name' --raw-output) == "$skuName" ]
25+
[ $(echo $whpInfo | jq '.sku.capacity' --raw-output) -eq $capacity ]
26+
27+
printf "\n3. Set the appservice plan: %s " "$whpName"
28+
newTier="Shared"
29+
newCapacity=0
30+
newSize="Medium"
31+
setPlanInfo=`azure app service plan set -n $whpName -g $groupName --tier $newTier --workers --workers $newCapacity --size $newSize`
32+
[ $(echo $setPlanInfo | jq '.name' --raw-output) == "$whpName" ]
33+
[ $(echo $setPlanInfo | jq '.sku.tier' --raw-output) == "$newTier" ]
34+
[ $(echo $setPlanInfo | jq '.sku.capacity' --raw-output) -eq $newCapacity ]
35+
[ $(echo $setPlanInfo | jq '.sku.name' --raw-output) == "D1" ]
36+
[ $(echo $setPlanInfo | jq '.["properties.geoRegion"]' --raw-output) == "West US" ]
37+
38+
whpName2=`randomName testplan`
39+
printf "\n4. Creating a new app service plan: %s" "$whpName2"
40+
location2="East US"
41+
azure app service plan create -n "$whpName2" -g "$groupName" -l "$location2" --tier "$tier" --size "$size" --workers "$capacity"
42+
43+
printf "\n5. Get All app service plans by name: %s" "$whpName2"
44+
whpInfo2=`azure app service plan get --name $whpName2`
45+
[ $(echo $whpInfo | jq '.name' --raw-output) == "$whpName2" ]
46+
[ $(echo $whpInfo | jq '.location' --raw-output) == "$location2" ]
47+
[ $(echo $whpInfo | jq '.sku.tier' --raw-output) == "$tier" ]
48+
[ $(echo $whpInfo | jq '.sku.name' --raw-output) == "$skuName" ]
49+
[ $(echo $whpInfo | jq '.sku.capacity' --raw-output) -eq $capacity ]
50+
51+
printf "\n6. Get All app service plans by resource group: %s" "$groupName"
52+
plansByGroup=`azure app service plan get --group $groupName`
53+
[ $plansByGroup == *"$whpName"* ]
54+
[ $plansByGroup == *"$whpName2"* ]
55+
56+
printf "\n7. Get All app service plans by location: %s" "$location2"
57+
plansByLocation=`azure app service plan get -l $location2`
58+
[ $plansByLocation == *"$whpName2"* ]
59+
60+
printf "\n8. Get All app service plans in a subscription."
61+
plansInSubscription=`azure app service plan get`
62+
[ $plansInSubscription == *"$whpName"* ]
63+
[ $plansInSubscription == *"$whpName2"* ]
64+
65+
printf "\n9. Remove app service plan: %s." "$whpName"
66+
azure app service plan remove -n $whpName -g $groupName
67+
68+
printf "\n10. Remove app service plan: %s." "$whpName2"
69+
azure app service plan remove -n $whpName2 -g $groupName
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#!/bin/bash
2+
set -e
3+
printf "\n=== Managing Web App Slot in Azure ===\n"
4+
5+
pingwebapp() {
6+
# a helper function to ping a webapp
7+
}
8+
9+
#setup
10+
printf "\nSetup: Creating a new resource group: %s at location: %s.\n" "$groupName" "$location"
11+
12+
appName=`randomName testweb`
13+
slotname1="staging"
14+
slotname2="testing"
15+
planName=`randomName testplan`
16+
tier="Standard"
17+
apiversion="2015-08-01"
18+
resourceType="Microsoft.Web/sites"
19+
20+
azure group create --name "$groupName" --location "$location"
21+
22+
printf "\n1. Create a new app service plan %s " "$planName"
23+
azure app service plan create -n "$planName" -g "$groupName" -l "$location" --tier "$tier"
24+
25+
printf "\n2. Create a new web app %s " "$appName"
26+
webappInfo=`azure webapp create -g "$groupName" -n "$appName" -l "$location" --plan "$planName"`
27+
28+
printf "\nValidating web app name %s " "$appName"
29+
[ $(echo $webappInfo | jq '.name' --raw-output) == "$appName" ]
30+
31+
printf "\n3. Create a web app slot %s " "$slotname1"
32+
slot1=`azure webapp slot create -g "$groupName" --plan "$planName" -n "$appName" --slot "$slotname1"`
33+
appWithSlotName1="$appName/$slotname1"
34+
35+
printf "\nValidating web app slot %s " "$slotname1"
36+
[ $(echo $slot1 | jq '.name' --raw-output) == "$appWithSlotName1" ]
37+
38+
printf "\nValidating web app slot get for %s " "$slotname1"
39+
slot1=`azure webapp slot get -g "$groupName" -n "$appName" --slot "$slotname1"`
40+
[ $(echo $slot1 | jq '.name' --raw-output) == "$appWithSlotName1" ]
41+
42+
printf "\nValidating web app slot via pipline obj for %s " "$slotname1"
43+
slot1=`echo "$webappInfo" | azure webapp slot get --slot "$slotname1"`
44+
45+
printf "\n4. Create another web app slot %s " "$slotname2"
46+
slot2=`azure webapp slot create -g "$groupName" --plan "$planName" -n "$appName" --slot "$slotname2"`
47+
appWithSlotName2="$appName/$slotname2"
48+
49+
printf "\n5. Get the webapp slots:"
50+
slots=`azure webapp slot get -g "$groupName" -n "$appName"`
51+
slotN1=`echo $slots | jq '.[0].name'`
52+
slotN2=`echo $slots | jq '.[1].name'`
53+
slotNames=`echo $slotN1 $slotN2`
54+
55+
printf "\nValidating web app slots %s " "$slotname1 and $slotname2"
56+
[[ $slotNames == *"$appWithSlotName1"* ]]
57+
[[ $slotNames == *"$appWithSlotName2"* ]]
58+
59+
printf "\n6. Change web app slot %s service plan" "$slotname2"
60+
printf "\n7. Set web app slot %s config properties" "$slotname2"
61+
printf "\n8. Set web app slot %s settings and connection strings" "$slotname2"
62+
63+
printf "\n9. Get web app slot %s publishing profile" "$slotname1"
64+
printf "\n10. Get web app slot %s publishing profile via pipline obj" "$slotname1"
65+
66+
printf "\n11. Get web app slot metrics %s " "$slotname1"
67+
for i in {1..10}
68+
do
69+
pingwebapp $slot1
70+
done
71+
72+
endTime=`date +"%A, %B %d, %Y %X"`
73+
startTime=`date +"%A, %B %d, %Y %X" --date "3 hour ago"`
74+
$metricsNames="\"('CPU', 'Requests')\""
75+
76+
# !Not able to test since complex object issue.
77+
metrics=`azure webapp slot metrics get -g "$groupName" -n "$appName" --slot "$slotname1" --granularity PT1M --starttime "$startTime" --endtime "$endTime" --metrics "$metricsNames"`
78+
79+
printf "\nValidating web app slot metrics %s " "$slotname1"
80+
for i in $metricsNames
81+
do
82+
[ $(echo $metrics ) == "$i" ]
83+
done
84+
85+
# !Not able to test pipeline for now
86+
printf "\nValidating web app slot metrics via pipline obj %s " "$slotname1"
87+
88+
printf "\n12. Stop web app slot: %s." "$slotname1"
89+
slot1=`echo "$slot1" | azure webapp slot stop`
90+
printf "\nValidating web app slot %s stopped " "$slotname1"
91+
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Stopped" ]
92+
93+
printf "\n13 Stop web app slot: %s." "$slotname1"
94+
slot1=`echo "$slot1" | azure webapp slot start`
95+
printf "\nValidating web app slot %s running " "$slotname1"
96+
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Running" ]
97+
98+
printf "\n14 Stop web app slot: %s." "$slotname1"
99+
slot1=`echo "$slot1" | azure webapp slot stop`
100+
printf "\nValidating web app slot %s stopped " "$slotname1"
101+
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Stopped" ]
102+
103+
printf "\n15 Stop web app slot: %s." "$slotname1"
104+
slot1=`echo "$slot1" | azure webapp slot start`
105+
printf "\nValidating web app slot %s running " "$slotname1"
106+
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Running" ]
107+
108+
printf "\n16 Restart web app slot: %s." "$slotname1"
109+
slot1=`echo "$slot1" | azure webapp slot restart`
110+
printf "\nValidating web app slot %s Running " "$slotname1"
111+
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Running" ]
112+
113+
printf "\n17 Restart web app slot: %s." "$slotname1"
114+
slot1=`echo "$slot1" | azure webapp slot restart`
115+
printf "\nValidating web app slot %s Running " "$slotname1"
116+
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Running" ]
117+
118+
# Clone ------
119+
# !Not able to test since complex object input issue.
120+
# printf "\n10. Clone web app slot: %s." "$slotname1"
121+
# slotClone=`azure web app slot clone`
122+
# appWithSlotNameClone="$appName/slotname1"
123+
124+
# printf "\nValidating cloned web app slot %s " "$slotname1"
125+
# [ $(echo $slotClone | jq '.name' --raw-output) == "$appWithSlotNameClone" ]
126+
127+
# printf "\nValidating web app slot get for %s " "$slotname1"
128+
# slot1=`azure webapp slot get -g "$groupName" -n "$appName" --slot "$slotname1"`
129+
# [ $(echo $slot1 | jq '.name' --raw-output) == "$appWithSlotNameClone" ]
130+
#-------
131+
132+
# Cleanup
133+
printf "\n20. Remove web app slot: %s." "$slotname1"
134+
azure webapp slot remove -g "$groupName" -n "$appName" --slot "$slotname1"
135+
136+
printf "\n20. Remove web app: %s." "$appName"
137+
azure webapp remove -g "$groupName" -n "$appName"
138+
139+
printf "\n20. Remove app service plan: %s." "$planName"
140+
azure app service plan remove -g "$groupName" -n "$planName"
141+
142+
printf "\n20. Remove resource group: %s." "$groupName"

0 commit comments

Comments
 (0)