Skip to content

Commit

Permalink
Merge pull request #1 from Azure/clu
Browse files Browse the repository at this point in the history
Clu branch update
  • Loading branch information
BurtBiel committed Jan 8, 2016
2 parents d1cb437 + 364a997 commit 5887150
Show file tree
Hide file tree
Showing 42 changed files with 806 additions and 903 deletions.
4 changes: 3 additions & 1 deletion clu-getstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

### Prerequsites

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).
* 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).

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.

* 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

### Project Artifacts

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.
Expand Down
4 changes: 2 additions & 2 deletions examples/resource-management/03-Deployments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName"
azure group create --name "$groupName" --location "$location"

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

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

printf "\n4. Provisioning Deployment\n"
deploymentInfo=`azure group deployment create --Name "$resourceName" --ResourceGroupName "$groupName" --TemplateFile $BASEDIR/sampleTemplate.json --TemplateParameterFile $BASEDIR/sampleTemplateParams.json`
Expand Down
3 changes: 2 additions & 1 deletion examples/resource-management/04-RoleAssignments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ azure role assignment create --ObjectId "$userId" --RoleDefinitionId "$roleDefin

printf "\n3. Delete last created Role Assignment.\n"
assignments=$(azure role assignment get)
assignmentId=$(echo $assignments | cat | jq '.[-1].ObjectId' -s --raw-output)
assignmentId=$(echo $assignments | cat | jq '.[-1:][0].ObjectId' -s --raw-output)
echo "Deleting assignment: $assignmentId"
azure role assignment remove --ObjectId "$assignmentId" --Scope "$scope" --RoleDefinitionId "$roleDefinitionId" -f
export MSYS_NO_PATHCONV=
20 changes: 7 additions & 13 deletions examples/resource-management/sampleTemplate.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"siteName": {
Expand All @@ -11,16 +11,6 @@
"siteLocation": {
"type": "string"
},
"sku": {
"type": "string",
"allowedValues": [
"Free",
"Shared",
"Basic",
"Standard"
],
"defaultValue": "Free"
},
"workerSize": {
"type": "int",
"allowedValues": [
Expand All @@ -33,13 +23,17 @@
},
"resources": [
{
"apiVersion": "2014-04-01",
"apiVersion": "2015-08-01",
"name": "[parameters('hostingPlanName')]",
"type": "Microsoft.Web/serverfarms",
"location": "[parameters('siteLocation')]",
"sku": {
"name": "S1",
"tier": "Standard",
"capacity": 1
},
"properties": {
"name": "[parameters('hostingPlanName')]",
"sku": "[parameters('sku')]",
"workerSize": "[parameters('workerSize')]",
"numberOfWorkers": 1
}
Expand Down
3 changes: 0 additions & 3 deletions examples/resource-management/sampleTemplateParams.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"siteLocation": {
"value": "West US"
},
"sku": {
"value": "Standard"
},
"workerSize": {
"value": 0
}
Expand Down
69 changes: 69 additions & 0 deletions examples/webapp-management/01-AppServicePlan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash
set -e
printf "\n=== Managing App Service Plans in Azure ===\n"

#setup
printf "\nSetup: Creating a new resource group: %s at location: %s.\n" "$groupName" "$location"
export whpName=`randomName testplan`
tier="Standard"
size="Medium"
capacity=2
skuName="S2"
azure 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"

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

printf "\nValidating app service plan name: %s\n" "$whpName"
[ $(echo $whpInfo | jq '.name' --raw-output) == "$whpName" ]
[ $(echo $whpInfo | jq '.location' --raw-output) == "West US" ]
[ $(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 "\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`
[ $(echo $setPlanInfo | jq '.name' --raw-output) == "$whpName" ]
[ $(echo $setPlanInfo | jq '.sku.tier' --raw-output) == "$newTier" ]
[ $(echo $setPlanInfo | jq '.sku.capacity' --raw-output) -eq $newCapacity ]
[ $(echo $setPlanInfo | jq '.sku.name' --raw-output) == "D1" ]
[ $(echo $setPlanInfo | jq '.["properties.geoRegion"]' --raw-output) == "West US" ]

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"

printf "\n5. Get All app service plans by name: %s" "$whpName2"
whpInfo2=`azure 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 == *"$whpName"* ]
[ $plansByGroup == *"$whpName2"* ]

printf "\n7. Get All app service plans by location: %s" "$location2"
plansByLocation=`azure 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 == *"$whpName"* ]
[ $plansInSubscription == *"$whpName2"* ]

printf "\n9. Remove app service plan: %s." "$whpName"
azure 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
142 changes: 142 additions & 0 deletions examples/webapp-management/02-WebAppSlot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#!/bin/bash
set -e
printf "\n=== Managing Web App Slot in Azure ===\n"

pingwebapp() {
# a helper function to ping a webapp
}

#setup
printf "\nSetup: Creating a new resource group: %s at location: %s.\n" "$groupName" "$location"

appName=`randomName testweb`
slotname1="staging"
slotname2="testing"
planName=`randomName testplan`
tier="Standard"
apiversion="2015-08-01"
resourceType="Microsoft.Web/sites"

azure 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"

printf "\n2. Create a new web app %s " "$appName"
webappInfo=`azure 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"`
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"`
[ $(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"`

printf "\n4. Create another web app slot %s " "$slotname2"
slot2=`azure 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"`
slotN1=`echo $slots | jq '.[0].name'`
slotN2=`echo $slots | jq '.[1].name'`
slotNames=`echo $slotN1 $slotN2`

printf "\nValidating web app slots %s " "$slotname1 and $slotname2"
[[ $slotNames == *"$appWithSlotName1"* ]]
[[ $slotNames == *"$appWithSlotName2"* ]]

printf "\n6. Change web app slot %s service plan" "$slotname2"
printf "\n7. Set web app slot %s config properties" "$slotname2"
printf "\n8. Set web app slot %s settings and connection strings" "$slotname2"

printf "\n9. Get web app slot %s publishing profile" "$slotname1"
printf "\n10. Get web app slot %s publishing profile via pipline obj" "$slotname1"

printf "\n11. Get web app slot metrics %s " "$slotname1"
for i in {1..10}
do
pingwebapp $slot1
done

endTime=`date +"%A, %B %d, %Y %X"`
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"`

printf "\nValidating web app slot metrics %s " "$slotname1"
for i in $metricsNames
do
[ $(echo $metrics ) == "$i" ]
done

# !Not able to test pipeline for now
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`
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`
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`
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`
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`
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`
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`
# 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"`
# [ $(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"

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

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

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

0 comments on commit 5887150

Please sign in to comment.