Skip to content

Clu #110

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 50 commits into from
Jan 20, 2016
Merged

Clu #110

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
3565529
[Fixes #111709626] - Update CliCommandAlias attribute to accept space…
stankovski Jan 14, 2016
8a770bb
Merge pull request #1653 from stankovski/clu
stankovski Jan 14, 2016
31af46a
[Delivers #111707132] Get the CLU cmd names for telemetry
stankovski Jan 14, 2016
bc27cbd
Merge pull request #1655 from stankovski/clu
stankovski Jan 14, 2016
00efff5
Added changes for clu helps
arroyc Jan 14, 2016
693e074
[Fixed #111708772] Removed duplicate error output
stankovski Jan 14, 2016
5a1048d
Fix bad warning message.
Jan 14, 2016
e216de3
Merge pull request #1657 from stankovski/clu
Jan 14, 2016
a1180bf
Merge remote-tracking branch 'upstream/clu' into clu
arroyc Jan 14, 2016
5438685
Merge pull request #327 from Azure/clu
huangpf Jan 14, 2016
5e7f12b
Merge pull request #1 from Azure/clu
arroyc Jan 14, 2016
cb558a6
Merge branch 'clu' of https://github.com/arroyc/azure-powershell into…
arroyc Jan 14, 2016
473f58f
Merge pull request #1658 from hovsepm/clu
Jan 14, 2016
a0996dd
Added Telemetry to CLU
stankovski Jan 14, 2016
379cc8b
Merge pull request #328 from Azure/clu
huangpf Jan 14, 2016
43b752c
Merge pull request #1660 from stankovski/clu
stankovski Jan 14, 2016
be5bf64
Merge pull request #329 from Azure/clu
huangpf Jan 14, 2016
3b47868
added help files and updated as per code review comments
arroyc Jan 15, 2016
3e1d6a3
Merge pull request #2 from Azure/clu
arroyc Jan 15, 2016
6bb4338
Merge pull request #1656 from arroyc/clu
markcowl Jan 15, 2016
1af1ccb
Update build script to include help directory (if available) in gener…
johanste Jan 15, 2016
b93c17f
Merge pull request #330 from Azure/clu
huangpf Jan 15, 2016
41dd4e7
Merge pull request #1663 from johanste/UpdateBuildToIncludeHelpDirectory
devigned Jan 15, 2016
1e78893
Merge pull request #331 from Azure/clu
huangpf Jan 15, 2016
0732135
Renaming resource cmdlets
markcowl Jan 16, 2016
ae763a3
rename compute cmdlets
markcowl Jan 16, 2016
a294ee6
Rename storage cmdlets
markcowl Jan 16, 2016
5dbe92a
Updating context cmdlet to map to subscription
markcowl Jan 16, 2016
9f19993
Updating command alias attributes to use spaces for resource manager
markcowl Jan 16, 2016
cbc88b4
Updating cmdlet aliases to use spaces for generic resource cmdlets
markcowl Jan 16, 2016
2b1bc5d
Added Dockerfile for testing
stankovski Jan 16, 2016
29a2ac2
Merge pull request #1668 from stankovski/clu
stankovski Jan 16, 2016
04fde66
Added steps for docker setup and run
stankovski Jan 16, 2016
62e01dd
Merge pull request #1669 from stankovski/clu
stankovski Jan 16, 2016
d2f184b
Updatign tests for new resource cmdlet names
markcowl Jan 16, 2016
6ac033b
Merge pull request #332 from Azure/clu
huangpf Jan 16, 2016
19b267f
Updating data collection to choose the first cmdlet alias attribute i…
markcowl Jan 19, 2016
25ac47a
remove 7zip from repo
yugangw-msft Jan 19, 2016
2576418
Merge pull request #1677 from yugangw-msft/7zip
yugangw-msft Jan 19, 2016
43f5113
Merge pull request #333 from Azure/clu
huangpf Jan 19, 2016
e03da5e
Rename help for new cmdlet names
markcowl Jan 19, 2016
e39eae0
Rename storage help
markcowl Jan 19, 2016
4550647
Merge pull request #1670 from markcowl/renameres
markcowl Jan 19, 2016
cdd5cb6
Merge compute cmdlet name changes with attribute format changes
markcowl Jan 19, 2016
de7b45e
Updating help and tests for cmdlet rename
markcowl Jan 19, 2016
4d62fda
Updating storage account names and tests
markcowl Jan 19, 2016
488ccc4
Corecting line endings
markcowl Jan 20, 2016
d01830f
Merge pull request #335 from Azure/clu
huangpf Jan 20, 2016
1a2268b
Merge pull request #1681 from markcowl/renamecompute
markcowl Jan 20, 2016
44b46cb
Merge pull request #337 from Azure/clu
huangpf Jan 20, 2016
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
  •  
  •  
  •  
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git
drop/clurun/osx.10.10-x64
drop/clurun/win7-x64
drop/CommandRepo
setup/*
src/artifacts
src/Common
src/ResourceManager
src/ServiceManagement
42 changes: 42 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
FROM graemef/docker-ubuntu-mono

ENV DNX_VERSION 1.0.0-rc1-final
ENV DNX_USER_HOME /opt/dnx

# Install DNX prerequisites
RUN apt-get update && \
apt-get -qqy install \
libunwind8 \
gettext \
libssl-dev \
libcurl4-gnutls-dev \
zlib1g \
libicu-dev \
uuid-dev \
curl \
unzip \
jq

RUN curl -sSL https://raw.githubusercontent.com/aspnet/Home/dev/dnvminstall.sh | DNX_USER_HOME=$DNX_USER_HOME DNX_BRANCH=v$DNX_VERSION sh

RUN bash -c "source $DNX_USER_HOME/dnvm/dnvm.sh \
&& dnvm install $DNX_VERSION -r coreclr -alias default \
&& dnvm alias default | xargs -i ln -s $DNX_USER_HOME/runtimes/{} $DNX_USER_HOME/runtimes/default"

ENV PATH $PATH:$DNX_USER_HOME/runtimes/default/bin

ADD drop/clurun/ubuntu.14.04-x64 ubuntu.14.04-x64
ADD src/CLU test/clu
ADD tools tools
ADD examples examples

WORKDIR /test/clu

RUN bash -c "source $DNX_USER_HOME/dnvm/dnvm.sh \
&& nuget source enable -Name https://www.nuget.org/api/v2/ \
&& dnu restore \
|| dnvm use $DNX_VERSION -r coreclr"

ENV PATH /ubuntu.14.04-x64:$PATH

WORKDIR /test/clu/Commands.Common.ScenarioTest
70 changes: 57 additions & 13 deletions clu-getstart.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Work on CLU cmdlets

### Prerequsites
## 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).

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
## 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 Expand Up @@ -47,7 +47,7 @@ CLUPackages require some additional files to direct generation of indexing, and
}
```

### Package Creation and Testing
## Package Creation and Testing
Two options
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.
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.
Expand All @@ -62,7 +62,7 @@ To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, copy the flav

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

### Quick introductions on cmdlets
## Quick introductions on cmdlets
* Run commands using the ‘az’ prefix, cmdlet nouns, and cmdlet verbs, for example, `az env get` maps to the cmdlet `Get-AzureRmEnvironment`
* 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"`
* To log in, 3 options
Expand All @@ -82,19 +82,19 @@ To test on osx/linux boxes, do #1, open `<repo-root>\drop\clurun`, copy the flav

```set AzureProfile=1010 ```

### Testing Cmdlets
## Testing Cmdlets

#### Environment setup (Windows)
### Environment setup (Windows)
- Install latest version of [Git for Windows](https://git-scm.com/download/win) that has `bash 4.x` available.
- Install `jq` using chocolatey `choco install jq` (chocolatey can be installed from [here](https://chocolatey.org/)).

#### Test Infrastructure
### Test Infrastructure
Testing will consist of scenario tests and unit tests. Scenario tests should be written in a form of an example and be available in `.ps1` and `.sh` formats.

#### Scenario Tests
### Scenario Tests
- Scenario tests should be saved under `./examples` directory with one directory per package. Each scenario tests should (eventually) consist of both `.ps1` and `.sh` files and should cover "P0" scenarios.

##### Environment Variables for Authentication
#### Environment Variables for Authentication
Please set the environment variables for either Username/Password (no 2FA) or ServicePrincipal authentication:

**Username/Password (without 2-factor auth):**
Expand All @@ -114,7 +114,7 @@ Please set the environment variables for either Username/Password (no 2FA) or Se
| tenant | The tenant guid to authenticate against |
| spnSubscription | (optional) Selects a particular subscription by id. If not provided, the first listed subscription will be selected |

##### XUnit Automation For Bash Scenario Tests
#### XUnit Automation For Bash Scenario Tests
- The ```Commands.Common.ScenarioTest``` project contains classes that enable executing bash scenario tests in Visual Studio, or cross-platform using dnx.

- To implement an xunit bash scenario test you must
Expand Down Expand Up @@ -161,24 +161,68 @@ runner.EnvironmentVariables.Add("myVariableName", runner.GenerateName("myres"));
| ExamplesDirectory | The path to the 'examples' directory ($pshome/examples) |
| TestDirectory | The path to the directory where logs will be written |

##### Running Bash Tests using Bash shell
#### Running Tests in Docker
##### Docker Setup
**Option 1 - VirtualBox:**
Install ToolBox from this link - https://docs.docker.com/engine/installation/windows/

**Option 2 - Hyper-V:**

1. Install ToolBox from this link - https://docs.docker.com/engine/installation/windows/ (uninstall VirtualBox afterwards)
2. http://sa.muel.be/2015/run-docker-on-hyper-v-with-docker-machine/
* Increase VHD to 100GB (--hyperv-disk-size 100000)
* List of other switches for create command - https://docs.docker.com/machine/drivers/hyper-v/

##### Workflow
1. Build packages (see [instructions](#package-creation-and-testing))
2. From command line with admin priveleges navigate to azure-powershell root folder and run ```docker build .```
3. Copy image id from the output. For example in the output below the image id is *26f067684da3*:

```
Successfully built 26f067684da3
```
4. Run ```docker run -it [IMAGEID]``` to SSH into the Docker image
5. In the SSH window run:

```bash
export azureUser=<[email protected]>
export password=<your_password>
export userSubscription=<subscription>
export spn=<spn-guid>
export secret=<spn-secret>
export tenant=<spn-tenant>
export spnSubscription=<subscription>
export azureUser=<[email protected]>
export password=<your_password>
dnx test
```


#### Running Bash Tests using Bash shell
- Bash tests should be runnable from bash shell in windows/linux/mac environments.
- To manually run the tests; please set [environment variables](#Environment_Variables_for_Authentication) for authentication as well as update PATH and run `./examples/lib/testrunner.sh`

```bash
export azureUser=<[email protected]>
export password=<your_password>
export userSubscription=<subscription>
export spn=<spn-guid>
export secret=<spn-secret>
export tenant=<spn-tenant>
export spnSubscription=<subscription>
export azureUser=<[email protected]>
export password=<your_password>
export PATH=/<path-to-drop>/clurun/win7-x64/:$PATH
```
- All the parameters to the cmdlets should be passed in as environment variables
- The current test runners will provide a unique resource group name via `$groupName` but may not remove it at the end if the test fails.
- The location for ARM will be provided via variable `$location`.
- "jq" package and BASH assert (e.g. `[ "foo" == "bar" ]`) should be used to validate the responses.

##### PowerShell Tests
#### PowerShell Tests
TODO: Add section on PowerShell testing

#### Unit Tests
### Unit Tests
TODO: Add section on unit testing


6 changes: 3 additions & 3 deletions examples/compute-management/02-VirtualMachineCreation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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 resourcemanager group create -n "$groupName" --location "$location"
az resource group create -n "$groupName" --location "$location"

printf "\n2. Creating a new storage account '%s' in type '%s'.\n" "$storageAccountName" "$storageAccountType"
az storage account create--resourcegroupname "$groupName" --name "$storageAccountName" --location "$location" --type "$storageAccountType"
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 create--name test --resourcegroupname "$groupName" --location "$location" --subnetid "$subnetId"
az vnet 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 @@ -33,4 +33,4 @@ printf "\n5. Create virtual machine with\r\nnicId='%s'\r\nvhdUri='%s'\r\nvmStr='
az vm create--resourcegroupname "$groupName" --location "$location" --vmprofile "$vmStr"

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

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

printf "\n3. Get information about resource group : %s.\n" "$groupName"
resourceGroupInfo=`az resourcemanager group ls -n $groupName`
resourceGroupInfo=`az resource 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 resourcemanager group ls
az resource group ls

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

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

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 resourcemanager resource create --Name $resourceName --Location $location --Tags "$tags" --ResourceGroupName $groupName --ResourceType $resourceType --PropertyObject "$properties" --ApiVersion $apiversion --Force
az 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 resourcemanager resource ls -n $resourceName)
resourceInfo=$(az 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 resourcemanager resource find -n "$resourceName" -t $resourceType)
foundResource=$(az 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 resourcemanager resource set --ResourceGroupName $groupName --ResourceName $resourceName --ResourceType $resourceType --Tags "$tagsUpdate" -f
az resource set --ResourceGroupName $groupName --ResourceName $resourceName --ResourceType $resourceType --Tags "$tagsUpdate" -f

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

printf "\n8. Removing resource: %s.\n" "$resourceName"
foundResource=$(az resourcemanager resource find -n "$resourceName" -t $resourceType)
foundResource=$(az resource find -n "$resourceName" -t $resourceType)
resourceId=$(echo $foundResource | jq '.ResourceId' --raw-output)
echo $resourceId
export MSYS_NO_PATHCONV=1
az resourcemanager resource rm --Id "$resourceId" -f
az 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 resourcemanager group create --name "$groupName" --location "$location"
az resource group create --name "$groupName" --location "$location"

printf "\n2. Test template with dynamic parameters\n"
az resourcemanager group deployment test -g "$groupName" --templatefile $BASEDIR/sampleTemplate.json --siteName "$resourceName" --hostingPlanName "$resourceName" --siteLocation "$location" --workerSize "0"
az resource 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 resourcemanager group deployment test -g "$groupName" --templatefile $BASEDIR/sampleTemplate.json --templateparameterobject "{\"siteName\":\"$resourceName\",\"hostingPlanName\":\"$resourceName\",\"siteLocation\":\"$location\",\"workerSize\": 0 }"
az resource 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 resourcemanager group deployment create --Name "$resourceName" --ResourceGroupName "$groupName" --TemplateFile $BASEDIR/sampleTemplate.json --TemplateParameterFile $BASEDIR/sampleTemplateParams.json`
deploymentInfo=`az resource group deployment create --Name "$resourceName" --ResourceGroupName "$groupName" --TemplateFile $BASEDIR/sampleTemplate.json --TemplateParameterFile $BASEDIR/sampleTemplateParams.json`
echo $deploymentInfo
12 changes: 6 additions & 6 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 resourcemanager group create --name "$groupName" --location "$location"
az resource group create --name "$groupName" --location "$location"

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

printf "\n3. Delete last created Role Assignment.\n"
assignments=$(az networksecurityrole assignment ls)
assignments=$(az resource role assignment ls)
assignmentId=$(echo $assignments | cat | jq '.[-1:][0].ObjectId' -s --raw-output)
echo "Deleting assignment: $assignmentId"
az networksecurityrole assignment rm --ObjectId "$assignmentId" --Scope "$scope" --RoleDefinitionId "$roleDefinitionId" -f
az resource role 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 resourcemanager group create --name "$groupName" --location "$location"
az resource group create --name "$groupName" --location "$location"

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

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

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

printf "\n5. Delete Role Definition.\n"
roleDefinitionId=$(echo $roleDefinition | jq '.Id' --raw-output)
az networksecurityrole definition rm --Id $roleDefinitionId --PassThru -f
az resource role definition rm --Id $roleDefinitionId --PassThru -f
export MSYS_NO_PATHCONV=
Loading