Skip to content

Commit

Permalink
Merge pull request #6 from Azure/clu
Browse files Browse the repository at this point in the history
Clu
  • Loading branch information
BurtBiel committed Jan 15, 2016
2 parents a3b2e12 + 6bb4338 commit 707df41
Show file tree
Hide file tree
Showing 641 changed files with 10,110 additions and 639 deletions.
8 changes: 4 additions & 4 deletions examples/compute-management/02-VirtualMachineCreation.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"
az resourcemanager group create -n "$groupName" --location "$location"

printf "\n2. Creating a new storage account '%s' in type '%s'.\n" "$storageAccountName" "$storageAccountType"
az storage account new --resourcegroupname "$groupName" --name "$storageAccountName" --location "$location" --type "$storageAccountType"
az storage account create--resourcegroupname "$groupName" --name "$storageAccountName" --location "$location" --type "$storageAccountType"

printf "\n3. Create virtual network.\n"
result=`az vnet new --resourcegroupname "$groupName" --name test --location "$location" --addressprefix "[\"10.0.0.0/16\"]" --subnet "[{\"Name\":\"test\",\"AddressPrefix\":\"10.0.0.0/24\"}]" --force`
result=`az vnet create--resourcegroupname "$groupName" --name test --location "$location" --addressprefix "[\"10.0.0.0/16\"]" --subnet "[{\"Name\":\"test\",\"AddressPrefix\":\"10.0.0.0/24\"}]" --force`

contextResult=`az context ls`

Expand All @@ -19,7 +19,7 @@ subnetId="/subscriptions/$subId/resourceGroups/$groupName/providers/Microsoft.Ne

printf "\n4. Create network interface with:\r\nsubId='%s' \r\n& \r\nsubnetId='$subnetId'.\n" "$subId"
export MSYS_NO_PATHCONV=1
az networkinterface new --name test --resourcegroupname "$groupName" --location "$location" --subnetid "$subnetId"
az networkinterface create--name test --resourcegroupname "$groupName" --location "$location" --subnetid "$subnetId"
export MSYS_NO_PATHCONV=

nicId="/subscriptions/$subId/resourceGroups/$groupName/providers/Microsoft.Network/networkInterfaces/test"
Expand All @@ -30,7 +30,7 @@ vmStr="{\"Name\":\"test\",\"HardwareProfile\":{\"VmSize\":\"Standard_A1\"},\"Net

printf "\n5. Create virtual machine with\r\nnicId='%s'\r\nvhdUri='%s'\r\nvmStr='%s'\n" "$nicId" "$vhdUri" "$vmStr"

az vm new --resourcegroupname "$groupName" --location "$location" --vmprofile "$vmStr"
az vm create--resourcegroupname "$groupName" --location "$location" --vmprofile "$vmStr"

printf "\n6. Removing resource group: %s.\n" "$groupName"
az resourcemanager group rm -n "$groupName" -f
2 changes: 1 addition & 1 deletion examples/lib/loginService.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/env/bash
az account add --spn --appid "$spn" --secret "$secret" -t "$tenant" -s "$spnSubscription"
az login --spn --appid "$spn" --secret "$secret" -t "$tenant" -s "$spnSubscription"
2 changes: 1 addition & 1 deletion examples/lib/loginUser.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/env/bash
az account add -u "$azureUser" -p "$password" -s "$userSubscription"
az login -u "$azureUser" -p "$password" -s "$userSubscription"
6 changes: 3 additions & 3 deletions examples/resource-management/02-Resource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ destinationGroupName=$groupName"Destination"

printf "\n2. Registering Resource Provider Namespace.\n"
providerNamespace="Providers.Test"
az resourcemanager resource resourcemanager provider register --ProviderNamespace $providerNamespace --Force
az resourcemanager resource provider register --ProviderNamespace $providerNamespace --Force

printf "\n3. Creating a new Resource: %s.\n" "$resourceName"
resourceType="$providerNamespace/statefulResources"
Expand All @@ -33,13 +33,13 @@ az resourcemanager resource set --ResourceGroupName $groupName --ResourceName $r

printf "\n7. Move Resource to resource group: %s.\n" "$destinationGroupName"
az resourcemanager group create --name "$destinationGroupName" --location "$location"
resourceId=$(echo $resourceInfo | jq '.Id')
resourceId=$(echo $resourceInfo | jq '.ResourceId')
arrayId="[$resourceId]"
az resourcemanager resource move -g "$destinationGroupName" --ResourceId "$arrayId" -f

printf "\n8. Removing resource: %s.\n" "$resourceName"
foundResource=$(az resourcemanager resource find -n "$resourceName" -t $resourceType)
resourceId=$(echo $foundResource | jq '.Id' --raw-output)
resourceId=$(echo $foundResource | jq '.ResourceId' --raw-output)
echo $resourceId
export MSYS_NO_PATHCONV=1
az resourcemanager resource rm --Id "$resourceId" -f
Expand Down
2 changes: 1 addition & 1 deletion examples/webapp-management/01-AppServicePlan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ setPlanInfo=`az appservice plan set -n $whpName -g $groupName --tier $newTier --
[ $(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" ]
[ $(echo $setPlanInfo | jq '.["geoRegion"]' --raw-output) == "West US" ]

whpName2=`randomName testplan`
printf "\n4. Creating a new app service plan: %s" "$whpName2"
Expand Down
52 changes: 26 additions & 26 deletions examples/webapp-management/02-WebAppSlot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e
printf "\n=== Managing Web App Slot in Azure ===\n"

pingwebapp() {
url=`echo "$1" | jq '."properties.hostNames"[0]' --raw-output`
url=`echo "$1" | jq '."HostNames"[0]' --raw-output`
curl -I `echo "$url"`
}

Expand All @@ -27,18 +27,18 @@ printf "\n2. Create a new web app %s " "$appName1"
webappInfo1=`az appservice create -g "$groupName" -n "$appName1" -l "$location" --plan "$planName1"`

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

printf "\n3. Create a web app slot %s " "$slotname1"
slot1=`az appservice slot create -g "$groupName" --plan "$planName1" -n "$appName1" --slot "$slotname1"`
appWithSlotName1="$appName1/$slotname1"

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

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

printf "\nValidating web app slot via pipline obj for %s " "$slotname1"
slot1=`echo "$webappInfo1" | az appservice slot ls --slot "$slotname1"`
Expand All @@ -49,22 +49,22 @@ appWithSlotName2="$appName1/$slotname2"

printf "\n5. Get the webapp slots:"
slots=`az appservice slot ls -g "$groupName" -n "$appName1"`
slotN1=`echo $slots | jq '.[0].name'`
slotN2=`echo $slots | jq '.[1].name'`
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"
servicePlanInfo2=`az app service plan create -n "$planName2" -g "$groupName" -l "$location" --tier "$tier2"`
servicePlanInfo2=`az appservice plan create -n "$planName2" -g "$groupName" -l "$location" --tier "$tier2"`
# slot3=`az appservice slot create -g "$groupName" --plan "$planName3" -n "$appName" --slot "$slotname2"`
slot1=`az appservice slot set -g "$groupName" -n "$appName1" --slot "$slotname1" --plan "$planName2"`

printf "\nValidating web app slots %s " "$slotname1"
[ $(echo $slot1 | jq '.name' --raw-output) == "$appName1/$slotname1" ]
[[ $(echo $slot1 | jq '."properties.serverFarmId"') == *"$planName2"* ]]
[ $(echo $slot1 | jq '.Name' --raw-output) == "$appName1/$slotname1" ]
[[ $(echo $slot1 | jq '."ServerFarmId"') == *"$planName2"* ]]

printf "\n7. Set web app slot %s config properties"
# Unable to test pipline. verity property name and value instead.
Expand All @@ -77,11 +77,11 @@ slot1=`az appservice slot set -g "$groupName" --plan "$planName1" -n "$appName1"
printf "\n9. Get web app slot %s publishing profile" "$slotname1"
outputFile1="webappslot-profile-1"
outputFile2="webappslot-profile-2"
az appservice slot profile get -g "$groupName" -n "$appName1" --slot "$slotname1" --outputfile "$outputFile1"
az appservice slot profile ls -g "$groupName" -n "$appName1" --slot "$slotname1" --outputfile "$outputFile1"

printf "\n10. Get web app slot %s publishing profile via pipline obj" "$slotname1"
# Unable to test pipline. verity property name and value instead.
# echo "$slot1" | az appservice slot profile get --outputfile "$outputFile2"
# echo "$slot1" | az appservice slot profile ls --outputfile "$outputFile2"

printf "\nValidating web app slot profile output file"
[ -s "$outputFile1" ]
Expand All @@ -100,72 +100,72 @@ metrics=`az appservice slot metrics ls -g "$groupName" -n "$appName1" --slot "$s

printf "\nValidating web app slot metrics via pipline obj %s " "$slotname1"
# Unable to test pipline. verity property name and value instead.
# echo "$slot1" | az appservice slot metrics get --metrics "$metricsNames" --starttime "$startTime" --endtime "$endTime" --granularity PT1M
# echo "$slot1" | az appservice slot metrics ls --metrics "$metricsNames" --starttime "$startTime" --endtime "$endTime" --granularity PT1M

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

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

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

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

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

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

# Need to create a 'Premium' plan for clone test
printf "\n18. Create a new web app for clone testing"
location1="eastus"

az app service plan set -n "$planName1" -g "$groupName" --tier "$tier2"
az appservice plan set -n "$planName1" -g "$groupName" --tier "$tier2"
webappInfo2=`az appservice create -g "$groupName" -n "$appName3" -l "$location" --plan "$planName1"`

printf "\n19. Clone web app slot to a slot."
slotClone=`az appservice slot create -g "$groupName" -n "$appName3" --slot "$slotname3" --sourcewebapp "$webappInfo2"`
appWithSlotNameClone="$appName3/$slotname3"

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

printf "\nValidating web app slot get for %s " "$slotname3"
slotClone=`az appservice slot get -g "$groupName" -n "$appName3" --slot "$slotname3"`
[ $(echo $slotClone | jq '.name' --raw-output) == "$appWithSlotNameClone" ]
slotClone=`az appservice slot ls -g "$groupName" -n "$appName3" --slot "$slotname3"`
[ $(echo $slotClone | jq '.Name' --raw-output) == "$appWithSlotNameClone" ]

printf "\n20. Create a new web app for clone testing"
slot2=`az appservice slot create -g "$groupName" --plan "$planName1" -n "$appName3" --slot "$slotname3"`

printf "\n21. Create a new web app for clone testing"
servicePlan=`az app service plan create -n "$planName3" -g "$groupName" -l "$location1" --tier "$tier2"`
servicePlan=`az appservice plan create -n "$planName3" -g "$groupName" -l "$location1" --tier "$tier2"`
webappInfo3=`az appservice create -g "$groupName" -n "$appName4" -l "$location1" --plan "$planName3"`
slot3=`az appservice slot create -g "$groupName" --plan "$planName3" -n "$appName4" --slot "$slotname3" --sourcewebapp "$slot2"`

printf "\nValidating web app slot get for %s " "$slotname3"
printf "\nValidating web app slot ls for %s " "$slotname3"
appWithSlotName3="$appName4/$slotname3"
[ $(echo $slot3 | jq '.name' --raw-output) == "$appWithSlotName3" ]
[ $(echo $slot3 | jq '.Name' --raw-output) == "$appWithSlotName3" ]

# Cleanup
printf "\n22. Remove web app slot: %s." "$slotname1"
az appservice slot rm -g "$groupName" -n "$appName1" --slot "$slotname1" --force
az appservice slot rm -g "$groupName" -n "$appName1" --slot "$slotname2" --force

printf "\n23. Remove resource group: %s." "$groupName"
az group rm --name "$groupName" --force
az resourcemanager group rm --name "$groupName" --force
32 changes: 16 additions & 16 deletions examples/webapp-management/03-WebApp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ result=`az appservice ls -g "$groupName" -n "$appName1"`
printf "\n3: Creating a new webapp: %s under resource group: %s.\n" "$appName2" "$groupName"
actual2=`az appservice create -g "$groupName" -l "$location" -n "$appName2" --plan "$planName1"`
[ $(echo $actual2 | jq '.name' --raw-output) == "$appName2" ]
[ $(echo $actual2 | jq '."properties.serverFarmId"' --raw-output) == $(echo $serverFarm | jq '.id' --raw-output) ]
[ $(echo $actual2 | jq '."serverFarmId"' --raw-output) == $(echo $serverFarm | jq '.id' --raw-output) ]

printf "\n4: Get WebApp by ResourceGroup: %s.\n" "$groupName"
count=`az appservice ls -g "$groupName"`
Expand Down Expand Up @@ -55,33 +55,33 @@ serverFarm2=`az appservice plan create -n "$planName2" -g "$groupName" -l "$loca
printf "\n10: Change webapp: %s to new service plan: %s\n" "$appName2" "$planName2"
changePlan=`az appservice set -g "$groupName" -n $appName2 --plan $planName2`
[ $(echo $changePlan | jq '.name' --raw-output) == "$appName2" ]
[ $(echo $changePlan | jq '."properties.serverFarmId"' --raw-output) == $(echo $serverFarm2 | jq '.id' --raw-output) ]
[ $(echo $changePlan | jq '."serverFarmId"' --raw-output) == $(echo $serverFarm2 | jq '.id' --raw-output) ]

printf "\n11: Set config properties 'httpLoggingEnabled' & 'requestTracingEnabled' of the webapp: %s to true.\n" "$appName2"
changePlan=`echo $changePlan | jq '."properties.siteConfig"."properties.httpLoggingEnabled"'=true`
changePlan=`echo $changePlan | jq '."properties.siteConfig"."properties.requestTracingEnabled"'=true`
changePlan=`echo $changePlan | jq '."siteConfig"."httpLoggingEnabled"'=true`
changePlan=`echo $changePlan | jq '."siteConfig"."requestTracingEnabled"'=true`
changePlan=`echo $changePlan | az appservice set`
[ $(echo $changePlan | jq '.name' --raw-output) == "$appName2" ]
[ $(echo $changePlan | jq '."properties.serverFarmId"' --raw-output) == $(echo $serverFarm2 | jq '.id' --raw-output) ]
[ $(echo $changePlan | jq '."properties.siteConfig"."properties.httpLoggingEnabled"' --raw-output) == true ]
[ $(echo $changePlan | jq '."properties.siteConfig"."properties.requestTracingEnabled"' --raw-output) == true ]
[ $(echo $changePlan | jq '."serverFarmId"' --raw-output) == $(echo $serverFarm2 | jq '.id' --raw-output) ]
[ $(echo $changePlan | jq '."siteConfig"."httpLoggingEnabled"' --raw-output) == true ]
[ $(echo $changePlan | jq '."siteConfig"."requestTracingEnabled"' --raw-output) == true ]

printf "\n12: Set appsettings and connectionstrings of the webapp: %s.\n" "$appName2"
appsettings="{\"setting1\":\"valueA\",\"setting2\":\"valueB\"}"
constr="{ \"connstring1\": { \"Type\": \"MySql\", \"Value\": \"string value 1\" }, \"connstring2\": { \"Type\": \"SqlAzure\", \"Value\": \"string value 2\" } }"

setconn=`az appservice set -g "$groupName" -n "$appName2" --appsettings "$appsettings" --connectionstrings "$constr"`
[ $(echo $setconn | jq '.name' --raw-output) == "$appName2" ]
[ $(echo $setconn | jq '."properties.siteConfig"."properties.appSettings" | length') -eq 2 ]
[ $(echo $setconn | jq '."properties.siteConfig"."properties.connectionStrings" | length') -eq 2 ]
[ $(echo $setconn | jq '."siteConfig"."appSettings" | length') -eq 2 ]
[ $(echo $setconn | jq '."siteConfig"."connectionStrings" | length') -eq 2 ]

app=`echo $setconn | jq -r '."properties.siteConfig"."properties.appSettings"'`
app=`echo $setconn | jq -r '."siteConfig"."appSettings"'`
[ $(echo $app | jq -r '.[0].name') == "setting2" ]
[ $(echo $app | jq -r '.[0].value') == "valueB" ]
[ $(echo $app | jq -r '.[0].name') == "setting1" ]
[ $(echo $app | jq -r '.[0].value') == "valueA" ]

conexn=`echo $setconn | jq -r '."properties.siteConfig"."properties.connectionStrings"'`
conexn=`echo $setconn | jq -r '."siteConfig"."connectionStrings"'`
[ $(echo $conexn | jq -r '.[0].name') == "connstring1" ]
[[ $(echo $conexn | jq -r '.[0].connectionString') == "string value 1" ]]
[ $(echo $conexn | jq -r '.[0].type') == "MySql" ]
Expand All @@ -92,27 +92,27 @@ conexn=`echo $setconn | jq -r '."properties.siteConfig"."properties.connectionSt
printf "\n13: Stop the webapp: %s.\n" "$appName2"
stop=`az appservice stop -g "$groupName" -n "$appName2"`
[ $(echo $stop | jq '.name' --raw-output) == "$appName2" ]
[ $(echo $stop | jq '."properties.state"' --raw-output) == "Stopped" ]
[ $(echo $stop | jq '."state"' --raw-output) == "Stopped" ]

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

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

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

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

printf "\n18: Creating a new app service plan: %s under resource group: %s with Premium tier.\n" "$planName3" "$groupName"
serverFarm3=`az appservice plan create -n "$planName3" -g "$groupName" -l "$location" --tier "$tier3"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public void DeploymentsTest()
public void RoleAssignmentsTest()
{
var helper = _collectionState
.LoginAsUser()
.LoginAsService()
.GetRunner("resource-management")
.RunScript("04-RoleAssignments");
}
Expand Down
14 changes: 7 additions & 7 deletions src/CLU/Commands.Common/AzurePSCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ public static bool IsDataCollectionAllowed()
//TODO: CLU - remove before final release
return true;

if (_dataCollectionProfile != null &&
_dataCollectionProfile.EnableAzureDataCollection.HasValue &&
_dataCollectionProfile.EnableAzureDataCollection.Value)
{
return true;
}
//if (_dataCollectionProfile != null &&
// _dataCollectionProfile.EnableAzureDataCollection.HasValue &&
// _dataCollectionProfile.EnableAzureDataCollection.Value)
//{
// return true;
//}

return false;
//return false;
}

/// <summary>
Expand Down
Loading

0 comments on commit 707df41

Please sign in to comment.