forked from a-patel/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathARM - Resource Group - Delete.ps1
150 lines (78 loc) · 3.24 KB
/
ARM - Resource Group - Delete.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
## To Set Verbose output
$PSDefaultParameterValues['*:Verbose'] = $true
# Variables - Common
$location = "eastus2"
$tags = New-Object 'System.Collections.Generic.Dictionary[String,object]'
$tags.Add("environment", "Production") # Production, Staging, QA
$tags.Add("projectName", "Demo Project")
$tags.Add("projectVersion", "1.0.0")
$tags.Add("managedBy", "[email protected]")
$tags.Add("billTo", "Ashish Patel")
$tags.Add("tier", "Front End") # Front End, Back End, Data
$tags.Add("dataProfile", "Public") # Public, Confidential, Restricted, Internal
<# Resource Group #>
# Variables - Resource Group
$rgShortName = "qweasdzxc"
$rgSuffix = "-rg"
$rgName = "${rgShortName}${rgSuffix}"
<# Create Resource Group, if it does not exist #>
Get-AzureRmResourceGroup -Name $rgName -ErrorVariable isRGExist -ErrorAction SilentlyContinue `
If ($isRGExist)
{
Write-Output "Resource Group does not exist"
Write-Verbose "Creating new Resource Group: {$rgName}"
$rg = New-AzureRmResourceGroup `
-Name $rgName `
-Location $location `
-Tag $tags
}
Else
{
Write-Output "Resource Group exist"
Write-Verbose "Fetching Resource Group: {$rgName}"
$rg = Get-AzureRmResourceGroup -Name $rgName
}
Write-Verbose "Get list of Resource Groups"
Write-Output "Resource Groups"
Get-AzureRmResourceGroup `
| Select-Object ResourceGroupName, Location `
| Format-Table -AutoSize -Wrap -GroupBy Location
<#
## Remove Resource Group
$rgShortName = "qweasdzxc"
$rgSuffix = "-rg"
$rgName = "${rgShortName}${rgSuffix}"
Write-Verbose "Delete Resource Group: {$rgName}"
Remove-AzureRmResourceGroup -Name $rgName -Force
#>
<#
## References
https://docs.microsoft.com/en-us/powershell/module/azurerm.resources/new-azurermresourcegroup?view=azurermps-6.13.0
https://docs.microsoft.com/en-us/powershell/module/azurerm.resources/get-azurermresourcegroup?view=azurermps-6.13.0
https://docs.microsoft.com/en-us/powershell/module/azurerm.resources/remove-azurermresourcegroup?view=azurermps-6.13.0
# Naming Conventions
https://docs.microsoft.com/en-us/azure/architecture/best-practices/naming-conventions
# Format table
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/format-table?view=powershell-6
# PowerShell style guide
https://github.com/PoshCode/PowerShellPracticeAndStyle
https://poshcode.gitbooks.io/powershell-practice-and-style/Style-Guide/Introduction.html
#>
<#
Create Resource Group (RG)
Create Virtual Network (VNet)
- Create Subnet(s) (WebSubnet, FrontendSubnet, BackendSubnet, MiddlewareSubnet)
- Note: Create Single subnet for single VM and multiple subnets for more than one VM
Create Network Security Group (NSG)
- Create Security Rules
Create Public IP (IP)
- Create DNS label
- Note: Public IP address needed for single Virtual Machine-VM (Public) or Load Balancer-LB (Public)
Create Network Interface Card (NIC)
- Configure Public/Private IP Address
- Create NIC for each VMs which should be placed in LB
Create Availability Set (AS)
Create Virtual Machine (VM)
Create Load Balancer (LB)
#>