-
Notifications
You must be signed in to change notification settings - Fork 7
/
ARM - Availability Set.ps1
96 lines (53 loc) · 2.17 KB
/
ARM - Availability Set.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
<# Availability Set #>
<#
#>
# Variables - Availability Set
$asShortName = "qweasdzxc"
$avSetSuffix = "-as"
$asName = "${asShortName}${avSetSuffix}"
<# Create an Azure Availability Set for VM high availability, if it does not exist #>
Get-AzureRmAvailabilitySet -Name $asName -ResourceGroupName $rgName -ErrorVariable isASExist -ErrorAction SilentlyContinue `
If ($isASExist)
{
Write-Output "Availability Set does not exist"
Write-Verbose "Creating new Availability Set: {$asName}"
$as = New-AzureRmAvailabilitySet `
-Name $asName `
-ResourceGroupName $rgName `
-Location $location `
-Sku Aligned `
-PlatformFaultDomainCount 2 `
-PlatformUpdateDomainCount 5 `
-Tag $tags
# -Sku 'Aligned' ` # Aligned: For managed disks or Classic: For unmanaged disks
}
Else
{
Write-Output "Availability Set exist"
Write-Verbose "Fetching Availability Set: {$asName}"
$as = Get-AzureRmAvailabilitySet -Name $asName -ResourceGroupName $rgName
}
Write-Verbose "Get list of Availability Set"
Write-Output "Availability Sets"
Get-AzureRmAvailabilitySet -ResourceGroupName $rgName `
| Select-Object Name, ResourceGroupName, Location `
| Format-Table -AutoSize -Wrap
<#
Get-AzureRmAvailabilitySet -ResourceGroupName $rgName `
| Select-Object Name, ResourceGroupName, Location `
| Format-Table -AutoSize -GroupBy ResourceGroupName -Wrap
#>
<#
## Remove Availability Set
$asShortName = "qweasdzxc"
$avSetSuffix = "-as"
$asName = "${asShortName}${avSetSuffix}"
Write-Verbose "Deleting Availability Set: {$asName}"
Remove-AzureRmAvailabilitySet -Name $asName -ResourceGroupName $rgName -Force
#>
<#
# References
https://docs.microsoft.com/en-us/powershell/module/azurerm.compute/new-azurermavailabilityset?view=azurermps-6.13.0
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
#>