-
Notifications
You must be signed in to change notification settings - Fork 3
/
template.deploy.ps1
41 lines (36 loc) · 1.26 KB
/
template.deploy.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<#
.SYNOPSIS
Deploys ARM template
.EXAMPLE
PS C:\> vm.deploy.ps1 -ResourceGroupName "vm-test-rg1" -Location "West Europe"
Deploys vm.json template with parameters from vm.parameters.json file
.NOTES
Script assumes convention over configuration approach.
If one will name all files correctly e.g.
vm.json
vm.parameters.json
vm.deploy.ps1
script will disassemble file names and process only the ones with proper name.
#>
[CmdletBinding()]
param (
$ResourceGroupName,
$Location
)
begin {
$templateName = $MyInvocation.MyCommand.Name.Split('.')[0]
$templateFile = Get-Item -Path "$PSScriptRoot\$templateName.json"
$templateParameterFile = Get-Item -Path "$PSScriptRoot\$templateName.parameters.json"
}
process {
$deploymentParameters = @{
Name = ('deployment' + '-' + ((Get-Date).ToUniversalTime()).ToString('MMdd-HHmm'))
ResourceGroupName = $resourceGroupName
TemplateFile = $templateFile
TemplateParameterFile = $templateParameterFile
Force = $true
Verbose = $true
}
New-AzureRmResourceGroup -Name $resourceGroupName -Location $location -Force
New-AzureRmResourceGroupDeployment @deploymentParameters
}