Skip to content

refresh web app example usage of azure to az #1611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions examples/webapp-management/01-AppServicePlan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ tier="Standard"
size="Medium"
capacity=2
skuName="S2"
azure group create --name "$groupName" --location "$location"
az group create --name "$groupName" --location "$location"

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

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

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

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

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

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

printf "\n8. Get All app service plans in a subscription."
plansInSubscription=`azure app service plan get`
plansInSubscription=`az app service plan get`
[ $plansInSubscription == *"$whpName"* ]
[ $plansInSubscription == *"$whpName2"* ]

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

printf "\n10. Remove app service plan: %s." "$whpName2"
azure app service plan remove -n $whpName2 -g $groupName
az app service plan remove -n $whpName2 -g $groupName
40 changes: 20 additions & 20 deletions examples/webapp-management/02-WebAppSlot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,37 +17,37 @@ tier="Standard"
apiversion="2015-08-01"
resourceType="Microsoft.Web/sites"

azure group create --name "$groupName" --location "$location"
az group create --name "$groupName" --location "$location"

printf "\n1. Create a new app service plan %s " "$planName"
azure app service plan create -n "$planName" -g "$groupName" -l "$location" --tier "$tier"
az app service plan create -n "$planName" -g "$groupName" -l "$location" --tier "$tier"

printf "\n2. Create a new web app %s " "$appName"
webappInfo=`azure webapp create -g "$groupName" -n "$appName" -l "$location" --plan "$planName"`
webappInfo=`az webapp create -g "$groupName" -n "$appName" -l "$location" --plan "$planName"`

printf "\nValidating web app name %s " "$appName"
[ $(echo $webappInfo | jq '.name' --raw-output) == "$appName" ]

printf "\n3. Create a web app slot %s " "$slotname1"
slot1=`azure webapp slot create -g "$groupName" --plan "$planName" -n "$appName" --slot "$slotname1"`
slot1=`az webapp slot create -g "$groupName" --plan "$planName" -n "$appName" --slot "$slotname1"`
appWithSlotName1="$appName/$slotname1"

printf "\nValidating web app slot %s " "$slotname1"
[ $(echo $slot1 | jq '.name' --raw-output) == "$appWithSlotName1" ]

printf "\nValidating web app slot get for %s " "$slotname1"
slot1=`azure webapp slot get -g "$groupName" -n "$appName" --slot "$slotname1"`
slot1=`az webapp slot get -g "$groupName" -n "$appName" --slot "$slotname1"`
[ $(echo $slot1 | jq '.name' --raw-output) == "$appWithSlotName1" ]

printf "\nValidating web app slot via pipline obj for %s " "$slotname1"
slot1=`echo "$webappInfo" | azure webapp slot get --slot "$slotname1"`
slot1=`echo "$webappInfo" | az webapp slot get --slot "$slotname1"`

printf "\n4. Create another web app slot %s " "$slotname2"
slot2=`azure webapp slot create -g "$groupName" --plan "$planName" -n "$appName" --slot "$slotname2"`
slot2=`az webapp slot create -g "$groupName" --plan "$planName" -n "$appName" --slot "$slotname2"`
appWithSlotName2="$appName/$slotname2"

printf "\n5. Get the webapp slots:"
slots=`azure webapp slot get -g "$groupName" -n "$appName"`
slots=`az webapp slot get -g "$groupName" -n "$appName"`
slotN1=`echo $slots | jq '.[0].name'`
slotN2=`echo $slots | jq '.[1].name'`
slotNames=`echo $slotN1 $slotN2`
Expand All @@ -74,7 +74,7 @@ startTime=`date +"%A, %B %d, %Y %X" --date "3 hour ago"`
$metricsNames="\"('CPU', 'Requests')\""

# !Not able to test since complex object issue.
metrics=`azure webapp slot metrics get -g "$groupName" -n "$appName" --slot "$slotname1" --granularity PT1M --starttime "$startTime" --endtime "$endTime" --metrics "$metricsNames"`
metrics=`az webapp slot metrics get -g "$groupName" -n "$appName" --slot "$slotname1" --granularity PT1M --starttime "$startTime" --endtime "$endTime" --metrics "$metricsNames"`

printf "\nValidating web app slot metrics %s " "$slotname1"
for i in $metricsNames
Expand All @@ -86,57 +86,57 @@ done
printf "\nValidating web app slot metrics via pipline obj %s " "$slotname1"

printf "\n12. Stop web app slot: %s." "$slotname1"
slot1=`echo "$slot1" | azure webapp slot stop`
slot1=`echo "$slot1" | az webapp slot stop`
printf "\nValidating web app slot %s stopped " "$slotname1"
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Stopped" ]

printf "\n13 Stop web app slot: %s." "$slotname1"
slot1=`echo "$slot1" | azure webapp slot start`
slot1=`echo "$slot1" | az webapp slot start`
printf "\nValidating web app slot %s running " "$slotname1"
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Running" ]

printf "\n14 Stop web app slot: %s." "$slotname1"
slot1=`echo "$slot1" | azure webapp slot stop`
slot1=`echo "$slot1" | az webapp slot stop`
printf "\nValidating web app slot %s stopped " "$slotname1"
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Stopped" ]

printf "\n15 Stop web app slot: %s." "$slotname1"
slot1=`echo "$slot1" | azure webapp slot start`
slot1=`echo "$slot1" | az webapp slot start`
printf "\nValidating web app slot %s running " "$slotname1"
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Running" ]

printf "\n16 Restart web app slot: %s." "$slotname1"
slot1=`echo "$slot1" | azure webapp slot restart`
slot1=`echo "$slot1" | az webapp slot restart`
printf "\nValidating web app slot %s Running " "$slotname1"
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Running" ]

printf "\n17 Restart web app slot: %s." "$slotname1"
slot1=`echo "$slot1" | azure webapp slot restart`
slot1=`echo "$slot1" | az webapp slot restart`
printf "\nValidating web app slot %s Running " "$slotname1"
[ $(echo $slot1 | jq '."properties.state"' --raw-output) == "Running" ]

# Clone ------
# !Not able to test since complex object input issue.
# printf "\n10. Clone web app slot: %s." "$slotname1"
# slotClone=`azure web app slot clone`
# slotClone=`az web app slot clone`
# appWithSlotNameClone="$appName/slotname1"

# printf "\nValidating cloned web app slot %s " "$slotname1"
# [ $(echo $slotClone | jq '.name' --raw-output) == "$appWithSlotNameClone" ]

# printf "\nValidating web app slot get for %s " "$slotname1"
# slot1=`azure webapp slot get -g "$groupName" -n "$appName" --slot "$slotname1"`
# slot1=`az webapp slot get -g "$groupName" -n "$appName" --slot "$slotname1"`
# [ $(echo $slot1 | jq '.name' --raw-output) == "$appWithSlotNameClone" ]
#-------

# Cleanup
printf "\n20. Remove web app slot: %s." "$slotname1"
azure webapp slot remove -g "$groupName" -n "$appName" --slot "$slotname1"
az webapp slot remove -g "$groupName" -n "$appName" --slot "$slotname1"

printf "\n20. Remove web app: %s." "$appName"
azure webapp remove -g "$groupName" -n "$appName"
az webapp remove -g "$groupName" -n "$appName"

printf "\n20. Remove app service plan: %s." "$planName"
azure app service plan remove -g "$groupName" -n "$planName"
az app service plan remove -g "$groupName" -n "$planName"

printf "\n20. Remove resource group: %s." "$groupName"
Loading