From 41b35e309b34eb19d51f04e2099a4b7a91c01003 Mon Sep 17 00:00:00 2001 From: Avinash Barnwal Date: Thu, 7 Dec 2017 21:02:25 +0530 Subject: [PATCH 1/7] Create createresources.sh Adding Bash Shell based Script for Creating Resources. --- deploy/az/createresources.sh | 79 ++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 deploy/az/createresources.sh diff --git a/deploy/az/createresources.sh b/deploy/az/createresources.sh new file mode 100644 index 000000000..d2b465e4e --- /dev/null +++ b/deploy/az/createresources.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +CreateGroup() +{ + echo Creating resource group $resource_group in '$location' + az group create --name $resource_group --location $location +} # end of system_info + + + +deployresources() +{ + echo Deploying ARM template '$path_and_filename.json' in resource group $resource_group + az group deployment create --resource-group $resource_group --parameters @$path_and_filename.parameters.json --template-file $path_and_filename.json +} + +Error_Usage() +{ + echo "" + echo Usage: + echo create-resources arm-file resource-group-name [-c location] + echo arm-file: Path to ARM template WITHOUT .json extension. An parameter file with same name plus '.parameters' MUST exist in same folder + echo resource-grop-name: Name of the resource group to use or create + echo -c: If appears means that resource group must be created. If -c is specified, must use enter location + echo "" + echo Examples: + echo "1 create-resources path_and_filename testgroup (Deploys path_and_filename.json with parameters specified in path_and_filename.parameters.json file)." + echo "2 create-resources path_and_filename newgroup -c westus (Deploys path_and_filename.json (with parameters specified in path_and_filename.parameters.json file) in a NEW resource group named newgroup in the westus location)" +} + + + +if [ $# -le 1 ]; then + Error_Usage + exit 1 +fi +if [ "$1" == "" ]; then + echo "path_and_filename is empty" + Error_Usage + exit 1 +fi + +if [ "$2" == "" ]; then + echo "Resource Group is empty" + Error_Usage + exit 1 +fi + +if [ ! -f "$1.json" ]; then + echo "$1.json doesn't exist" + exit 1 +fi + +if [ ! -f "$2.parameters.json" ]; then + echo "$2.parameters.json doesn't exist" + exit 1 +fi + + +path_and_filename=$1 +resource_group=$2 + + +if [ "$3" == "-c" ]; then + echo "Resource Group needs to be created" + if [ "$4" == "" ]; then + echo "but Resource Group name is missing" + Error_Usage + exit 1 + else + location=$4 + CreateGroup + fi + +fi +# if NOT $3.==-c. GOTO deployresources +deployresources + +echo "all finished successfully" From 9daa50f25c4e2ea498c753d1433efad583ca096b Mon Sep 17 00:00:00 2001 From: Avinash Barnwal Date: Thu, 7 Dec 2017 21:04:16 +0530 Subject: [PATCH 2/7] Update createresources.sh removed unnecessary line --- deploy/az/createresources.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/deploy/az/createresources.sh b/deploy/az/createresources.sh index d2b465e4e..16572d37d 100644 --- a/deploy/az/createresources.sh +++ b/deploy/az/createresources.sh @@ -73,7 +73,6 @@ if [ "$3" == "-c" ]; then fi fi -# if NOT $3.==-c. GOTO deployresources deployresources echo "all finished successfully" From 1398e7eebc71d1e216f477e927588f7600882ab4 Mon Sep 17 00:00:00 2001 From: Cesar De la Torre Date: Thu, 7 Dec 2017 08:59:39 -0800 Subject: [PATCH 3/7] Update readme.md --- deploy/az/readme.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/deploy/az/readme.md b/deploy/az/readme.md index cee4581cb..3fa56e885 100644 --- a/deploy/az/readme.md +++ b/deploy/az/readme.md @@ -1,7 +1,10 @@ + # Deploying resources using create-resources script The `create-resources` script is a basic script to allow easy deployment of one ARM template in one resource group. You can deploy to an existing resource group or to create one. +NOTE: Alternatively, you can also use the createresources.sh bash script which was created as a second option, convenient if you are using a Mac or Linux machine, or simply, bash on Windows, instead of CMD/CommandPrompt in Windows. + ## Deploying to a existing resource group Just type `create-resources path-to-arm-template resourcegroup`. Called this way the script will: From 9bbfd61c4d2911ae1d4f9b3f7e2c2420ffd132d6 Mon Sep 17 00:00:00 2001 From: Cesar De la Torre Date: Thu, 7 Dec 2017 09:02:08 -0800 Subject: [PATCH 4/7] Update readme.md --- deploy/az/readme.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/deploy/az/readme.md b/deploy/az/readme.md index 3fa56e885..803dc19b5 100644 --- a/deploy/az/readme.md +++ b/deploy/az/readme.md @@ -1,20 +1,20 @@ # Deploying resources using create-resources script -The `create-resources` script is a basic script to allow easy deployment of one ARM template in one resource group. You can deploy to an existing resource group or to create one. +The `create-resources.cmd ` script is a basic script to allow easy deployment of one ARM template in one resource group. You can deploy to an existing resource group or to create one. -NOTE: Alternatively, you can also use the createresources.sh bash script which was created as a second option, convenient if you are using a Mac or Linux machine, or simply, bash on Windows, instead of CMD/CommandPrompt in Windows. +NOTE: Alternatively, you can also use the `createresources.sh` bash script which was created as a second option, convenient if you are using a Mac or Linux machine, or simply, bash on Windows, instead of CMD/CommandPrompt in Windows. ## Deploying to a existing resource group -Just type `create-resources path-to-arm-template resourcegroup`. Called this way the script will: +Just type `create-resources [pathfile-to-arm-template] resourcegroup` from command-prompt. Called this way the script will: 1. Search for `path-to-arm-template.json` and `path-to-arm-template.parameters.json` files -2. If they exist, will deploy them in the `resourcegroup` specified (that has to exist). +2. If they exist, will deploy them in the `resourcegroup` specified (that resource group in Azure has to exist). ## Deploying to a new resource group -Just type `create-resources path-to-arm-template resourcegroup -c location`. Called this way the script will: +Just type `create-resources [pathfile-to-arm-template] resourcegroup -c location`. Called this way the script will: 1. Search for `path-to-arm-template.json` and `path-to-arm-template.parameters.json` files 2. If they exist, will create the `resourcegroup` specified in the `location` specified. From f4b0c1853469f4ddc8b659976930cacaf142f944 Mon Sep 17 00:00:00 2001 From: Cesar De la Torre Date: Thu, 7 Dec 2017 09:07:11 -0800 Subject: [PATCH 5/7] Update readme.md --- deploy/az/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deploy/az/readme.md b/deploy/az/readme.md index 803dc19b5..864aac542 100644 --- a/deploy/az/readme.md +++ b/deploy/az/readme.md @@ -3,7 +3,7 @@ The `create-resources.cmd ` script is a basic script to allow easy deployment of one ARM template in one resource group. You can deploy to an existing resource group or to create one. -NOTE: Alternatively, you can also use the `createresources.sh` bash script which was created as a second option, convenient if you are using a Mac or Linux machine, or simply, bash on Windows, instead of CMD/CommandPrompt in Windows. +**NOTE**: Alternatively, you can also use the `createresources.sh` bash script which was created as a second option, convenient if you are using the Azure Cloud Bash Shell, a Mac or Linux machine, or simply, bash on Windows, instead of CMD/CommandPrompt in a local Windows. ## Deploying to a existing resource group From 307ac5c25acbd1445809563cbadd80cef6336848 Mon Sep 17 00:00:00 2001 From: Avinash Barnwal Date: Thu, 7 Dec 2017 22:44:03 +0530 Subject: [PATCH 6/7] Update createresources.sh Added few Comments for clarity --- deploy/az/createresources.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deploy/az/createresources.sh b/deploy/az/createresources.sh index 16572d37d..3a71ca8fd 100644 --- a/deploy/az/createresources.sh +++ b/deploy/az/createresources.sh @@ -4,7 +4,7 @@ CreateGroup() { echo Creating resource group $resource_group in '$location' az group create --name $resource_group --location $location -} # end of system_info +} # end of CreateGroup() @@ -12,7 +12,7 @@ deployresources() { echo Deploying ARM template '$path_and_filename.json' in resource group $resource_group az group deployment create --resource-group $resource_group --parameters @$path_and_filename.parameters.json --template-file $path_and_filename.json -} +} # end of deployresources Error_Usage() { @@ -75,4 +75,4 @@ if [ "$3" == "-c" ]; then fi deployresources -echo "all finished successfully" +echo "all resources finished successfully" From 4e5d987aaeeb74d9b2617c77ac9eabd8ee438ff4 Mon Sep 17 00:00:00 2001 From: Avinash Barnwal Date: Thu, 7 Dec 2017 22:59:35 +0530 Subject: [PATCH 7/7] Update readme.md Updated Readme.md for Bash shell script --- deploy/az/readme.md | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/deploy/az/readme.md b/deploy/az/readme.md index 864aac542..7b07ea69c 100644 --- a/deploy/az/readme.md +++ b/deploy/az/readme.md @@ -3,16 +3,16 @@ The `create-resources.cmd ` script is a basic script to allow easy deployment of one ARM template in one resource group. You can deploy to an existing resource group or to create one. -**NOTE**: Alternatively, you can also use the `createresources.sh` bash script which was created as a second option, convenient if you are using the Azure Cloud Bash Shell, a Mac or Linux machine, or simply, bash on Windows, instead of CMD/CommandPrompt in a local Windows. +**NOTE**: Alternatively, you can also use the `createresources.sh` bash script which can be used as a second option, convenient if you are using the Azure Cloud Bash Shell, a Mac or Linux machine, or simply, bash on Windows, instead of CMD/CommandPrompt in a local Windows -## Deploying to a existing resource group +## Deploying to a existing resource group - Windows CMD Just type `create-resources [pathfile-to-arm-template] resourcegroup` from command-prompt. Called this way the script will: 1. Search for `path-to-arm-template.json` and `path-to-arm-template.parameters.json` files 2. If they exist, will deploy them in the `resourcegroup` specified (that resource group in Azure has to exist). -## Deploying to a new resource group +## Deploying to a new resource group - Windows CMD Just type `create-resources [pathfile-to-arm-template] resourcegroup -c location`. Called this way the script will: @@ -21,3 +21,20 @@ Just type `create-resources [pathfile-to-arm-template] resourcegroup -c location 3. Finally will deploy `path-to-arm-template.json` and `path-to-arm-template.parameters.json` files in the `resourcegroup` + +## Deploying to a existing resource group - Bash shell + +Just type `createresources.sh [pathfile-to-arm-template] resourcegroup` from command-prompt. Called this way the script will: + +1. Search for `path-to-arm-template.json` and `path-to-arm-template.parameters.json` files +2. If they exist, will deploy them in the `resourcegroup` specified (that resource group in Azure has to exist). + +## Deploying to a new resource group - Bash shell + +Just type `createresources.sh [pathfile-to-arm-template] resourcegroup -c location`. Called this way the script will: + +1. Search for `path-to-arm-template.json` and `path-to-arm-template.parameters.json` files +2. If they exist, will create the `resourcegroup` specified in the `location` specified. +3. Finally will deploy `path-to-arm-template.json` and `path-to-arm-template.parameters.json` files in the `resourcegroup` + +