-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmasterdeployaz.ps1
95 lines (67 loc) · 1.88 KB
/
masterdeployaz.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<#
.DESCRIPTION
Powershell Script Logic to Deploy resource type automating the name from resource tags.
#>
param (
[string] $resourceGroupName
)
$resourceGroup = Get-AzResourceGroup -Name $resourceGroupName -ErrorAction SilentlyContinue
$location=$resourceGroup.Location
if(!$resourceGroup)
{
Write-Host "Resource group '$resourceGroupName' does not exist. To create a new resource group, please enter a location.";
if(!$resourceGroupLocation) {
$resourceGroupLocation = Read-Host "resourceGroupLocation";
}
Write-Host "Creating resource group '$resourceGroupName' in location '$resourceGroupLocation'";
New-AzResourceGroup -Name $resourceGroupName -Location $location
}
else{
Write-Host "Using existing resource group '$resourceGroupName'";
}
$PN = $resourceGroup.Tags.ProductName
if($PN -ne "empty")
{
if($PN -eq "Product1")
}
else
{
Write-output ("Incorrect product name")
}
$env= ($resourceGroup.Tags.Environment.ToLower()).Trim()
$cus="-sha"
if($resourceGroup.Tags.Customer -eq "Customer1")
{
$cus="-cu1"
}
if($resourceGroup.location -ne "")
{
if($resourceGroup.location -eq "AustraliaSoutheast")
{
$loc="au-se"
}
if($resourceGroup.location -eq "AustraliaEast")
{
$loc="au-ea"
}
if($resourceGroup.location -eq "Australiacentral")
{
$loc="au-c1"
}
if($resourceGroup.location -eq "Australiacentral2")
{
$loc="au-c2"
}
}
else
{
Write-output ("Incorrect or unsupported location for naming")
}
$pn
$cus
$env
$loc
Write-Output ("##vso[task.setvariable variable=pn;]$pn")
Write-Output ("##vso[task.setvariable variable=cus;]$cus")
Write-Output ("##vso[task.setvariable variable=env;]$env")
Write-Output ("##vso[task.setvariable variable=loc;]$loc")