-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathCreate_an_Azure_Storage_Account.ps1
50 lines (37 loc) · 1.48 KB
/
Create_an_Azure_Storage_Account.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
Set-Location c:\
Clear-Host
Get-InstalledModule -Name "Az"
Install-Module -Name Az -Force -AllowClobber -Verbose
#Prefix for resources
$prefix = "tw"
#Basic variables
$location = "westeurope"
$id = Get-Random -Minimum 1000 -Maximum 9999
$storageaccountname = "$($prefix)sa$id"
$resourceGroup = "$prefix-rg-$id"
#Test the storage account name
Get-AzStorageAccountNameAvailability -Name $storageaccountname
#Log into Azure
Connect-AzAccount
#Select the correct subscription
Get-AzSubscription -SubscriptionName "MSDN Platforms" | Select-AzSubscription
Get-AzContext
#Create a new resource group
New-AzResourceGroup -Name $resourceGroup -Location $location
#Supported regions for your subscription
Get-AzLocation | select Location
#Create a general-purpose v2 storage account
New-AzStorageAccount -ResourceGroupName $resourceGroup `
-Name $storageaccountname `
-Location $location `
-SkuName Standard_RAGRS `
-Kind StorageV2
#Replication option SkuName parameter
#Locally redundant storage (LRS) Standard_LRS
#Zone-redundant storage (ZRS) Standard_ZRS
#Geo-redundant storage (GRS) Standard_GRS
#Read-access geo-redundant storage (GRS) Standard_RAGRS
#Geo-zone-redundant storage (GZRS) Standard_GZRS
#Read-access geo-zone-redundant storage (RA-GZRS) Standard_RAGZRS
#Clean Up
Remove-AzResourceGroup -Name $resourceGroup -Force