commit
						8c25f2028c
					
				
							
								
								
									
										78
									
								
								deploy/az/createresources.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								deploy/az/createresources.sh
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,78 @@ | |||||||
|  | #!/bin/bash | ||||||
|  | 
 | ||||||
|  | CreateGroup() | ||||||
|  | { | ||||||
|  | 	echo Creating resource group $resource_group in '$location' | ||||||
|  | 	az group create --name $resource_group --location $location | ||||||
|  | }   # end of CreateGroup() | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 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() | ||||||
|  | { | ||||||
|  | 	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 | ||||||
|  | deployresources | ||||||
|  | 
 | ||||||
|  | echo "all resources finished successfully" | ||||||
| @ -1,17 +1,37 @@ | |||||||
|  | 
 | ||||||
| # Deploying resources using create-resources script | # 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. | ||||||
| 
 | 
 | ||||||
| ## Deploying to a existing resource group | **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 | ||||||
| 
 | 
 | ||||||
| Just type `create-resources path-to-arm-template resourcegroup`. Called this way the script will: | ## 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 | 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 | ## Deploying to a new resource group - Windows CMD | ||||||
| 
 | 
 | ||||||
| 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. | ||||||
|  | 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 | 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. | 2. If they exist, will create the `resourcegroup` specified in the `location` specified. | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user