Skip to content

Clu #1620

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 12 commits into from
Jan 13, 2016
Merged

Clu #1620

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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
10 changes: 5 additions & 5 deletions examples/compute-management/01-VirtualMachineSizes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ set -e
printf "\n=== Managing Virtual Machine Sizes in Azure Compute ===\n"

printf "\n1. Showing VM size results in location: %s.\n" "$location"
az vmsize get --location "$location"
az vm size ls --location "$location"

printf "\n2. Checking VM size results in location: %s.\n" "$location"
vmSizeResult=`az vmsize get --location "$location"`
vmSizeResult=`az vm size ls --location "$location"`

if [[ $vmSizeResult == "" ]]; then
echo "Failure: No VM sizes!" 1>&2
Expand All @@ -15,23 +15,23 @@ else
echo "Success: Non-empty Results."
fi

filterResult=`az vmsize get --location "$location" | cat | jq 'select(.name | contains("Standard_A0"))' --raw-output`
filterResult=`az vm size ls --location "$location" | cat | jq 'select(.name | contains("Standard_A0"))' --raw-output`
if [[ "$filterResult" == "" ]]; then
echo "Failure: Standard_A0 vm size not found." 1>&2
exit 1
else
echo "Success: Standard_A0 vm size found."
fi

filterResult=`az vmsize get --location "$location" | cat | jq 'select(.name | contains("Standard_G1"))' --raw-output`
filterResult=`az vm size ls --location "$location" | cat | jq 'select(.name | contains("Standard_G1"))' --raw-output`
if [[ "$filterResult" == "" ]]; then
echo "Failure: Standard_G1 vm size not found." 1>&2
exit 1
else
echo "Success: Standard_G1 vm size found."
fi

filterResult=`az vmsize get --location "$location" | cat | jq 'select(.name | contains("NonStandard_A1"))' --raw-output`
filterResult=`az vm size ls --location "$location" | cat | jq 'select(.name | contains("NonStandard_A1"))' --raw-output`
if [[ "$filterResult" == "" ]]; then
echo "Success: NonStandard_A1 vm size not found."
else
Expand Down
10 changes: 5 additions & 5 deletions examples/compute-management/02-VirtualMachineCreation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ set -e
printf "\n=== Managing Virtual Machine Creation in Azure Compute ===\n"

printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
az group create -n "$groupName" --location "$location"
az resourcemanager group create -n "$groupName" --location "$location"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the most used cmdlet in the entire set opf cmdlets - you have to create a resource group to do anything else. Do we really want the cmdlet name to be so wordy?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joe/Jason would like to keep the resourcemanager term. Is it possible to create an alias for the term?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BurtBiel The decision we came to this morning was to use azure resourceGroup [verb]


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"

printf "\n3. Create virtual network.\n"
result=`az virtual network 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 new --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 get`
contextResult=`az context ls`

subId=`echo $contextResult | jq '.Subscription.SubscriptionId' --raw-output`

subnetId="/subscriptions/$subId/resourceGroups/$groupName/providers/Microsoft.Network/virtualNetworks/test/subnets/test"

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

nicId="/subscriptions/$subId/resourceGroups/$groupName/providers/Microsoft.Network/networkInterfaces/test"
Expand All @@ -33,4 +33,4 @@ printf "\n5. Create virtual machine with\r\nnicId='%s'\r\nvhdUri='%s'\r\nvmStr='
az vm new --resourcegroupname "$groupName" --location "$location" --vmprofile "$vmStr"

printf "\n6. Removing resource group: %s.\n" "$groupName"
az group remove -n "$groupName" -f
az resourcemanager group rm -n "$groupName" -f
2 changes: 1 addition & 1 deletion examples/lib/testrunner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ for d in $( ls $TESTDIR/.. --ignore=lib ); do
. $f
set +e
printf "\nCleanup: removing resource group: %s\n" $groupName
az group remove --name "$groupName" --force
az resourcemanager group rm --name "$groupName" --force
set -e
echo "success: $f"
done
Expand Down
10 changes: 5 additions & 5 deletions examples/resource-management/01-ResourceGroups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ set -e
printf "\n=== Managing Resource Groups in Azure ===\n"

printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
az group create -n "$groupName" --location "$location"
az resourcemanager group create -n "$groupName" --location "$location"

printf "\n2. Updating the group %s with tags.\n" "$groupName"
az group set -n "$groupName" --tags "[{\"Value\":\"testval\",\"Name\":\"testtag\"}]"
az resourcemanager group set -n "$groupName" --tags "[{\"Value\":\"testval\",\"Name\":\"testtag\"}]"

printf "\n3. Get information about resource group : %s.\n" "$groupName"
resourceGroupInfo=`az group get -n $groupName`
resourceGroupInfo=`az resourcemanager group ls -n $groupName`

printf "\nValidating resource group name is: %s\n" "$groupName"
[ $(echo $resourceGroupInfo | jq '.ResourceGroupName' --raw-output) == "$groupName" ]

printf "\n4. Listing all resource groups in the subscription.\n"
az group get
az resourcemanager group ls

printf "\n5. Removing resource group: %s.\n" "$groupName"
az group remove -n "$groupName" -f
az resourcemanager group rm -n "$groupName" -f
20 changes: 10 additions & 10 deletions examples/resource-management/02-Resource.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,44 @@ set -e
printf "\n=== Managing Resources in Azure ===\n"

printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
az group create --name "$groupName" --location "$location"
az resourcemanager group create --name "$groupName" --location "$location"
destinationGroupName=$groupName"Destination"

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, seems like 'resourcemanager' is wordy and unnecessary to disambiguate

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Joe or Jason may be able to comment on this further

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BurtBiel so this is clearly incorrect - even if we keep resourceManager, it should not appear twice.


printf "\n3. Creating a new Resource: %s.\n" "$resourceName"
resourceType="$providerNamespace/statefulResources"
tags='[{"Name": "testtag", "Value": "testvalue"}]'
properties='{"administratorLogin": "adminuser", "administratorLoginPassword": "P@ssword1"}'
apiversion="2014-04-01"
az resource create --Name $resourceName --Location $location --Tags "$tags" --ResourceGroupName $groupName --ResourceType $resourceType --PropertyObject "$properties" --ApiVersion $apiversion --Force
az resourcemanager resource create --Name $resourceName --Location $location --Tags "$tags" --ResourceGroupName $groupName --ResourceType $resourceType --PropertyObject "$properties" --ApiVersion $apiversion --Force

printf "\n4. Get information about Resource : %s.\n" "$resourceName"
resourceInfo=$(az resource get -n $resourceName)
resourceInfo=$(az resourcemanager resource ls -n $resourceName)
printf "\nValidating Resource name is: %s\n" "$resourceName"
[ $(echo $resourceInfo | jq '.Name' --raw-output) == "$resourceName" ]

printf "\n5. Find Resource with name '%s' and type '%s'.\n" "$resourceName" "$resourceType"
foundResource=$(az resource find -n "$resourceName" -t $resourceType)
foundResource=$(az resourcemanager resource find -n "$resourceName" -t $resourceType)
printf "\nValidating Resource name is: %s.\n" "$resourceName"
[ $(echo $foundResource | jq '.Name' --raw-output) == "$resourceName" ]

printf "\n6. Update Resource.\n"
tagsUpdate='[{"Name": "testtagUpdated", "Value": "testvalueUpdated"}]'
az resource set --ResourceGroupName $groupName --ResourceName $resourceName --ResourceType $resourceType --Tags "$tagsUpdate" -f
az resourcemanager resource set --ResourceGroupName $groupName --ResourceName $resourceName --ResourceType $resourceType --Tags "$tagsUpdate" -f

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

printf "\n8. Removing resource: %s.\n" "$resourceName"
foundResource=$(az resource find -n "$resourceName" -t $resourceType)
foundResource=$(az resourcemanager resource find -n "$resourceName" -t $resourceType)
resourceId=$(echo $foundResource | jq '.Id' --raw-output)
echo $resourceId
export MSYS_NO_PATHCONV=1
az resource remove --Id "$resourceId" -f
az resourcemanager resource rm --Id "$resourceId" -f
export MSYS_NO_PATHCONV=
8 changes: 4 additions & 4 deletions examples/resource-management/03-Deployments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ set -e
printf "\n=== Provisioning Deployments in Azure ===\n"

printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
az group create --name "$groupName" --location "$location"
az resourcemanager group create --name "$groupName" --location "$location"

printf "\n2. Test template with dynamic parameters\n"
az group deployment test -g "$groupName" --templatefile $BASEDIR/sampleTemplate.json --siteName "$resourceName" --hostingPlanName "$resourceName" --siteLocation "$location" --workerSize "0"
az resourcemanager 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"
az group deployment test -g "$groupName" --templatefile $BASEDIR/sampleTemplate.json --templateparameterobject "{\"siteName\":\"$resourceName\",\"hostingPlanName\":\"$resourceName\",\"siteLocation\":\"$location\",\"workerSize\": 0 }"
az resourcemanager group deployment test -g "$groupName" --templatefile $BASEDIR/sampleTemplate.json --templateparameterobject "{\"siteName\":\"$resourceName\",\"hostingPlanName\":\"$resourceName\",\"siteLocation\":\"$location\",\"workerSize\": 0 }"

printf "\n4. Provisioning Deployment\n"
deploymentInfo=`az group deployment create --Name "$resourceName" --ResourceGroupName "$groupName" --TemplateFile $BASEDIR/sampleTemplate.json --TemplateParameterFile $BASEDIR/sampleTemplateParams.json`
deploymentInfo=`az resourcemanager group deployment create --Name "$resourceName" --ResourceGroupName "$groupName" --TemplateFile $BASEDIR/sampleTemplate.json --TemplateParameterFile $BASEDIR/sampleTemplateParams.json`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is certainly in the top few commands used by everyone and this name is just too wordy. Why not az deployment create?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like it might be good wording, can you run it by Joe?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you thinking of promoting the Azure Group Deployment subcommand to be its own command?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BurtBiel @JasonRShaver The consensus was azure resourceGroup deployment create.

echo $deploymentInfo
14 changes: 7 additions & 7 deletions examples/resource-management/04-RoleAssignments.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ set -e
printf "\n=== Managing Role Assignments in Azure ===\n"

printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
az group create --name "$groupName" --location "$location"
az resourcemanager group create --name "$groupName" --location "$location"

printf "\n2. Creating a new Role Assignment.\n"
export MSYS_NO_PATHCONV=1
users=$(az ad users get)
users=$(az activedirectory users ls)
userId=$(echo $users | cat | jq '.[0].Id' -s --raw-output)
echo "UserID: $userId"
roleDefinitions=$(az role definition get)
roleDefinitions=$(az networksecurityrole definition ls)
roleDefinitionId=$(echo $roleDefinitions | cat | jq '.[0].Id' -s --raw-output)
echo "RoleDefinitionId: $roleDefinitionId"
subsciptions=$(az subscription get)
subsciptions=$(az subscription ls)
subscriptionId=$(echo $subsciptions | cat | jq '.[0].SubscriptionId' -s --raw-output)
scope="/subscriptions/$subscriptionId/resourceGroups/$groupName"
echo "Scope: $scope"
az role assignment create --ObjectId "$userId" --RoleDefinitionId "$roleDefinitionId" --Scope "$scope"
az networksecurityrole assignment create --ObjectId "$userId" --RoleDefinitionId "$roleDefinitionId" --Scope "$scope"

printf "\n3. Delete last created Role Assignment.\n"
assignments=$(az role assignment get)
assignments=$(az networksecurityrole assignment ls)
assignmentId=$(echo $assignments | cat | jq '.[-1:][0].ObjectId' -s --raw-output)
echo "Deleting assignment: $assignmentId"
az role assignment remove --ObjectId "$assignmentId" --Scope "$scope" --RoleDefinitionId "$roleDefinitionId" -f
az networksecurityrole assignment rm --ObjectId "$assignmentId" --Scope "$scope" --RoleDefinitionId "$roleDefinitionId" -f
export MSYS_NO_PATHCONV=
10 changes: 5 additions & 5 deletions examples/resource-management/05-RoleDefinitions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ set -e
printf "\n=== Managing Role Definitions in Azure ===\n"

printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
az group create --name "$groupName" --location "$location"
az resourcemanager group create --name "$groupName" --location "$location"

printf "\n2. Creating a new Role Definition.\n"
roleDefinition=$(az role definition create --inputfile $BASEDIR/roleDefinition.json)
roleDefinition=$(az networksecurityrole definition create --inputfile $BASEDIR/roleDefinition.json)

printf "\n3. Get information about Role Definitions.\n"
roleDefinitionName=$(echo $roleDefinition | jq '.Name' --raw-output)
az role definition get -n $roleDefinitionName
az networksecurityrole definition ls -n $roleDefinitionName

printf "\n4. Update Role Definition.\n"
export MSYS_NO_PATHCONV=1
updatedRoleDefinition=$(echo $roleDefinition | jq '.Actions |= .+ ["Microsoft.Authorization/*/write"]')
az role definition set --Role "$updatedRoleDefinition"
az networksecurityrole definition set --Role "$updatedRoleDefinition"

printf "\n5. Delete Role Definition.\n"
roleDefinitionId=$(echo $roleDefinition | jq '.Id' --raw-output)
az role definition remove --Id $roleDefinitionId --PassThru -f
az networksecurityrole definition rm --Id $roleDefinitionId --PassThru -f
export MSYS_NO_PATHCONV=
4 changes: 2 additions & 2 deletions examples/virtual-hard-disk/01-VirtualHardDisks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e
printf "\n=== Managing Virtual Hard Disks in Azure Compute ===\n"

printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
az group create -n "$groupName" --location "$location"
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"
Expand All @@ -25,4 +25,4 @@ else
fi

printf "\n6. Removing resource group: %s.\n" "$groupName"
az group remove -n "$groupName" -f
az resourcemanager group rm -n "$groupName" -f
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"
az group create --name "$groupName" --location "$location"
az resourcemanager group create --name "$groupName" --location "$location"

printf "\n1. Create a new app service plan %s " "$whpName"
az app service plan create -n "$whpName" -g "$groupName" -l "$location" --tier "$tier" --size "$size" --workers "$capacity"
az appservice 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=`az app service plan get --name $whpName --group $groupName`
whpInfo=`az appservice plan ls --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=`az app service plan set -n $whpName -g $groupName --tier $newTier --workers --workers $newCapacity --size $newSize`
setPlanInfo=`az appservice 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=`az app service plan set -n $whpName -g $groupName --tier $newTier -
whpName2=`randomName testplan`
printf "\n4. Creating a new app service plan: %s" "$whpName2"
location2="East US"
az app service plan create -n "$whpName2" -g "$groupName" -l "$location2" --tier "$tier" --size "$size" --workers "$capacity"
az appservice 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=`az app service plan get --name $whpName2`
whpInfo2=`az appservice plan ls --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=`az app service plan get --group $groupName`
plansByGroup=`az appservice plan ls --group $groupName`
[ $plansByGroup == *"$whpName"* ]
[ $plansByGroup == *"$whpName2"* ]

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

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

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

printf "\n10. Remove app service plan: %s." "$whpName2"
az app service plan remove -n $whpName2 -g $groupName
az appservice plan rm -n $whpName2 -g $groupName
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the distinction between appservice and webapp? We should decide on one noun for this and use it throughout:

az appservice create
az appservice plan create
az appservice slot create

etc.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to app service instead of webapp

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

appservice (one word) right?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branding is in fact two words: https://azure.microsoft.com/en-us/services/app-service/. But, one word is fine for the command itself.

Loading