Skip to content

Commit 8ee674f

Browse files
committed
Merge pull request #2 from Azure/clu
Clu branch update
2 parents 5887150 + ef850e3 commit 8ee674f

21 files changed

+145
-142
lines changed

build.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@
185185
DependsOnTargets="Build;Test" >
186186
<Exec Command="$(LibraryToolsFolder)\CLU\BuildAndInstallClu.bat" />
187187
<!--do a simple verification-->
188-
<Exec Command="$(LibraryRoot)drop\clurun\win7-x64\azure.bat help" />
188+
<Exec Command="$(LibraryRoot)drop\clurun\win7-x64\az.bat help" />
189189
</Target>
190190

191191
<Target Name="BuildMsBuildTask" DependsOnTargets="RestoreNugetPackages">

clu-getstart.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ CLUPackages require some additional files to direct generation of indexing, and
2525
| ------------- |:-------------:|
2626
| CommandAssemblies | File name of cmdlets assembly(ies) |
2727
| NounPrefix | ‘AzureRm’ The part of the cmdlet noun to remove in clu commands|
28-
| NounFirst | if true, the verb comes at the end of the command (e.g. azure resource get)|
28+
| NounFirst | if true, the verb comes at the end of the command (e.g. az resource get)|
2929

3030
* \<modulename\>.nuspec.template, which contains nuspec format metadata about the package – the base temaplate is in tools\clu\Microsoft.Azure.Commands.nuspec.template. Here are the special fields defined in this template:
3131
* %PackageId% - replace with the module name (Microsoft.Azure.Commands.\<rp-name\>)
@@ -52,31 +52,31 @@ CLUPackages require some additional files to direct generation of indexing, and
5252
1. Run `<repo-root>\tools\CLU\BuildAndInstallClu.bat` which build and generate all cmdlet packages and deploy to under `<repo root>\drop\clurun` folder, with 3 flavors `win7-x64`, `osx.10.10-x64` and `ubuntu.14.04-x64`. When you have a clean environment or just pull from upstream, you should clean temporary bits such as `git clean -xdf`, and run this command.
5353
2. Run `<repo-root>\tools\CLU\BuildCmdlet <package name like Microsoft.Azure.Commands.Profile>` <name like: Microsoft.Azure.Commands.Profile>", this will build and refresh an individual cmdlet package.
5454

55-
After #1 above is finished, you can run `drop\clurun\<platform>\azure.bat help` to explore.
55+
After #1 above is finished, you can run `drop\clurun\<platform>\az.bat help` to explore.
5656

5757
To debug, set environment variable of `DebugCLU` to "1". Then on running any command, you will be prompted to attach a debugger.
5858

59-
There is also `<repo-root>\tools\CLU\SetupEnv.bat` which is a windows batch wrapping around the `BuildAndInstallClu.bat`, plus set the `DebugCLU` for you, and add the `drop\clurun\win7-x64\azure.bat` to the PATH environment variable.
59+
There is also `<repo-root>\tools\CLU\SetupEnv.bat` which is a windows batch wrapping around the `BuildAndInstallClu.bat`, plus set the `DebugCLU` for you, and add the `drop\clurun\win7-x64\az.bat` to the PATH environment variable.
6060

61-
To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, copy the flavor folder to your target machine, and run the "azure.sh" inside. Make sure set execution permission using `chmod +x azure.sh clurun`
61+
To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, copy the flavor folder to your target machine, and run the "az.sh" inside. Make sure set execution permission using `chmod +x az.sh clurun`
6262

6363
(All of those are subject to change, contact yugangw or adxsdkdev for any questions)
6464

6565
### Quick introductions on cmdlets
66-
* Run commands using the ‘azure’ prefix, cmdlet nouns, and cmdlet verbs, for example, `azure environment get` maps to the cmdlet `Get-AzureRmEnvironment`
67-
* Cmdlet parameters use the double dash (--) so for example, getting a subscription with a particular name would be: `azure subscription get –-SubscriptionName “name of subscription"`
66+
* Run commands using the ‘az’ prefix, cmdlet nouns, and cmdlet verbs, for example, `az environment get` maps to the cmdlet `Get-AzureRmEnvironment`
67+
* Cmdlet parameters use the double dash (--) so for example, getting a subscription with a particular name would be: `az subscription get –-SubscriptionName “name of subscription"`
6868
* To log in, 3 options
69-
* login interactively using device flow, this is the only option for msa account or any org-id with 2fa enforced, example: `azure account add`
70-
* login with user and password, this works on org-id w/o 2fa enforced, example: `azure account add --Username [email protected] --Password password1`
71-
* login as service principal. Example: `azure account add --ServicePrincipal --TenantId <tenant> --ApplicationId <id> --Secret <secret>`
69+
* login interactively using device flow, this is the only option for msa account or any org-id with 2fa enforced, example: `az account add`
70+
* login with user and password, this works on org-id w/o 2fa enforced, example: `az account add --Username [email protected] --Password password1`
71+
* login as service principal. Example: `az account add --ServicePrincipal --TenantId <tenant> --ApplicationId <id> --Secret <secret>`
7272
* Piping between cmdlets should work the same way that Powerhell piping works
73-
```azure subscription get --SubscriptionName | azure context set```
73+
```az subscription get --SubscriptionName | az context set```
7474
* You can capture piped output using redirection to a file - the result will be the json serialization of the output object.
75-
```azure subscription get > subscriptions.json```
75+
```az subscription get > subscriptions.json```
7676
* You can use file input tu aparameter using '@' notation:
77-
```azure command --param1 @file1.json```
77+
```az command --param1 @file1.json```
7878
Reads input from file1.json and attempts to deserialize the .net object that is the Parameter type for ```param1```
79-
```azure command --param1 @@file1.json```
79+
```az command --param1 @@file1.json```
8080
Does the same thing, but treats the input from ```file1.json``` as if it come from the pipeline, so that multiple objects will result in multiple invocations of ```ProcessRecord()``` for the target cmdlet.
8181
* There are some known issues with the current approach to sessions, which can cause session variables to not be propagated when running cmdlets in a pipeline, to work around this, set the 'CmdletSessionId' environment variable to a numeric value - all cmdlets running from the shell will use that session id, and sessions will work with pipelining
8282

examples/compute-management/01-VirtualMachineSizes.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ set -e
33
printf "\n=== Managing Virtual Machine Sizes in Azure Compute ===\n"
44

55
printf "\n1. Showing VM size results in location: %s.\n" "$location"
6-
azure vmsize get --location "$location"
6+
az vmsize get --location "$location"
77

88
printf "\n2. Checking VM size results in location: %s.\n" "$location"
9-
vmSizeResult=`azure vmsize get --location "$location"`
9+
vmSizeResult=`az vmsize get --location "$location"`
1010

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

18-
filterResult=`azure vmsize get --location "$location" | cat | jq 'select(.name | contains("Standard_A0"))' --raw-output`
18+
filterResult=`az vmsize get --location "$location" | cat | jq 'select(.name | contains("Standard_A0"))' --raw-output`
1919
if [[ "$filterResult" == "" ]]; then
2020
echo "Failure: Standard_A0 vm size not found." 1>&2
2121
exit 1
2222
else
2323
echo "Success: Standard_A0 vm size found."
2424
fi
2525

26-
filterResult=`azure vmsize get --location "$location" | cat | jq 'select(.name | contains("Standard_G1"))' --raw-output`
26+
filterResult=`az vmsize get --location "$location" | cat | jq 'select(.name | contains("Standard_G1"))' --raw-output`
2727
if [[ "$filterResult" == "" ]]; then
2828
echo "Failure: Standard_G1 vm size not found." 1>&2
2929
exit 1
3030
else
3131
echo "Success: Standard_G1 vm size found."
3232
fi
3333

34-
filterResult=`azure vmsize get --location "$location" | cat | jq 'select(.name | contains("NonStandard_A1"))' --raw-output`
34+
filterResult=`az vmsize get --location "$location" | cat | jq 'select(.name | contains("NonStandard_A1"))' --raw-output`
3535
if [[ "$filterResult" == "" ]]; then
3636
echo "Success: NonStandard_A1 vm size not found."
3737
else

examples/compute-management/02-VirtualMachineCreation.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ set -e
33
printf "\n=== Managing Virtual Machine Creation in Azure Compute ===\n"
44

55
printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
6-
azure group create -n "$groupName" --location "$location"
6+
az group create -n "$groupName" --location "$location"
77

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

1111
printf "\n3. Create virtual network.\n"
12-
result=`azure 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`
12+
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`
1313

14-
contextResult=`azure context get`
14+
contextResult=`az context get`
1515

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

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

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

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

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

33-
azure vm new --resourcegroupname "$groupName" --location "$location" --vmprofile "$vmStr"
33+
az vm new --resourcegroupname "$groupName" --location "$location" --vmprofile "$vmStr"
3434

3535
printf "\n6. Removing resource group: %s.\n" "$groupName"
36-
azure group remove -n "$groupName" -f
36+
az group remove -n "$groupName" -f

examples/lib/loginService.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
azure account add --spn --appid "$spn" --secret "$secret" -t "$tenant" -s "$spnSubscription"
2+
az account add --spn --appid "$spn" --secret "$secret" -t "$tenant" -s "$spnSubscription"

examples/lib/loginUser.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
azure account add -u "$azureUser" -p "$password" -s "$userSubscription"
2+
az account add -u "$azureUser" -p "$password" -s "$userSubscription"

examples/lib/testrunner.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ for d in $( ls $TESTDIR/.. --ignore=lib ); do
1515
. $f
1616
set +e
1717
printf "\nCleanup: removing resource group: %s\n" $groupName
18-
azure group remove --name "$groupName" --force
18+
az group remove --name "$groupName" --force
1919
set -e
2020
echo "success: $f"
2121
done

examples/resource-management/01-ResourceGroups.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ set -e
33
printf "\n=== Managing Resource Groups in Azure ===\n"
44

55
printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
6-
azure group create -n "$groupName" --location "$location"
6+
az group create -n "$groupName" --location "$location"
77

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

1111
printf "\n3. Get information about resource group : %s.\n" "$groupName"
12-
resourceGroupInfo=`azure group get -n $groupName`
12+
resourceGroupInfo=`az group get -n $groupName`
1313

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

1717
printf "\n4. Listing all resource groups in the subscription.\n"
18-
azure group get
18+
az group get
1919

2020
printf "\n5. Removing resource group: %s.\n" "$groupName"
21-
azure group remove -n "$groupName" -f
21+
az group remove -n "$groupName" -f

examples/resource-management/02-Resource.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,44 @@ set -e
33
printf "\n=== Managing Resources in Azure ===\n"
44

55
printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
6-
azure group create --name "$groupName" --location "$location"
6+
az group create --name "$groupName" --location "$location"
77
destinationGroupName=$groupName"Destination"
88

99
printf "\n2. Registering Resource Provider Namespace.\n"
1010
providerNamespace="Providers.Test"
11-
azure resource provider register --ProviderNamespace $providerNamespace --Force
11+
az resource provider register --ProviderNamespace $providerNamespace --Force
1212

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

2020
printf "\n4. Get information about Resource : %s.\n" "$resourceName"
21-
resourceInfo=$(azure resource get -n $resourceName)
21+
resourceInfo=$(az resource get -n $resourceName)
2222
printf "\nValidating Resource name is: %s\n" "$resourceName"
2323
[ $(echo $resourceInfo | jq '.Name' --raw-output) == "$resourceName" ]
2424

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

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

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

4040
printf "\n8. Removing resource: %s.\n" "$resourceName"
41-
foundResource=$(azure resource find -n "$resourceName" -t $resourceType)
41+
foundResource=$(az resource find -n "$resourceName" -t $resourceType)
4242
resourceId=$(echo $foundResource | jq '.Id' --raw-output)
4343
echo $resourceId
4444
export MSYS_NO_PATHCONV=1
45-
azure resource remove --Id "$resourceId" -f
45+
az resource remove --Id "$resourceId" -f
4646
export MSYS_NO_PATHCONV=

examples/resource-management/03-Deployments.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ set -e
33
printf "\n=== Provisioning Deployments in Azure ===\n"
44

55
printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
6-
azure group create --name "$groupName" --location "$location"
6+
az 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" --workerSize "0"
9+
az 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\",\"workerSize\": 0 }"
12+
az 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"
15-
deploymentInfo=`azure group deployment create --Name "$resourceName" --ResourceGroupName "$groupName" --TemplateFile $BASEDIR/sampleTemplate.json --TemplateParameterFile $BASEDIR/sampleTemplateParams.json`
15+
deploymentInfo=`az group deployment create --Name "$resourceName" --ResourceGroupName "$groupName" --TemplateFile $BASEDIR/sampleTemplate.json --TemplateParameterFile $BASEDIR/sampleTemplateParams.json`
1616
echo $deploymentInfo

examples/resource-management/04-RoleAssignments.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,25 @@ set -e
33
printf "\n=== Managing Role Assignments in Azure ===\n"
44

55
printf "\n1. Creating a new resource group: %s and location: %s.\n" "$groupName" "$location"
6-
azure group create --name "$groupName" --location "$location"
6+
az group create --name "$groupName" --location "$location"
77

88
printf "\n2. Creating a new Role Assignment.\n"
99
export MSYS_NO_PATHCONV=1
10-
users=$(azure ad users get)
10+
users=$(az ad users get)
1111
userId=$(echo $users | cat | jq '.[0].Id' -s --raw-output)
1212
echo "UserID: $userId"
13-
roleDefinitions=$(azure role definition get)
13+
roleDefinitions=$(az role definition get)
1414
roleDefinitionId=$(echo $roleDefinitions | cat | jq '.[0].Id' -s --raw-output)
1515
echo "RoleDefinitionId: $roleDefinitionId"
16-
subsciptions=$(azure subscription get)
16+
subsciptions=$(az subscription get)
1717
subscriptionId=$(echo $subsciptions | cat | jq '.[0].SubscriptionId' -s --raw-output)
1818
scope="/subscriptions/$subscriptionId/resourceGroups/$groupName"
1919
echo "Scope: $scope"
20-
azure role assignment create --ObjectId "$userId" --RoleDefinitionId "$roleDefinitionId" --Scope "$scope"
20+
az role assignment create --ObjectId "$userId" --RoleDefinitionId "$roleDefinitionId" --Scope "$scope"
2121

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

0 commit comments

Comments
 (0)