-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy path15_Create_storage_account.ps1
39 lines (28 loc) · 1 KB
/
15_Create_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
Set-Location c:\
Clear-Host
# Install Powershell Modules
Install-Module Az -Verbose -Force -AllowClobber
# Connect to azure
Connect-AzAccount
Get-AzContext
Get-AzSubscription
Set-AzContext
# Are we connected?
Get-AzResourceGroup
# put resource group in a variable so you can use the same group name going forward,
# without hard-coding it repeatedly
Get-AzLocation | select Location
$resourceGroupName = Read-Host -Prompt "Enter the Resource Group name"
$location = Read-Host -Prompt "Enter the location (i.e. centralus)"
$storageAccountName = Read-Host -Prompt "Enter the storage account name"
#Test the storage account name
Get-AzStorageAccountNameAvailability -Name $storageAccountName
# Create the storage account
$storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroupName `
-Name $storageAccountName `
-Location $location `
-SkuName "Standard_RAGRS" `
-Kind StorageV2
# Retrieve the context
$ctx = $storageAccount.Context
Disconnect-AzAccount