Create Storage Group with Powershell
This Script will ask login details and then sets the context for your subscription id. Then it tries to find storage account inside given resource group and if not found then it creates with the same name.
Login-AzureRmAccount
Set-AzureRmContext -SubscriptionId "your subcription id"
$ResourceGroupName='test-rg'
$Location='Southeast Asia'
$storageSku = "Standard_LRS";
$StorageAccountName='testsa' #it should be unique
$SAccount = Get-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName -ErrorAction Ignore
if(-not $SAccount)
{
$SAccount= New-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName `
-Name $StorageAccountName `
-Type $storageSku `
-Location $Location `
-Kind Storage `
-EnableHttpsTrafficOnly $true `
-ErrorAction Stop
}
Login-AzureRmAccount
Set-AzureRmContext -SubscriptionId "your subcription id"
$ResourceGroupName='test-rg'
$Location='Southeast Asia'
$storageSku = "Standard_LRS";
$StorageAccountName='testsa' #it should be unique
$SAccount = Get-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName -ErrorAction Ignore
if(-not $SAccount)
{
$SAccount= New-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName `
-Name $StorageAccountName `
-Type $storageSku `
-Location $Location `
-Kind Storage `
-EnableHttpsTrafficOnly $true `
-ErrorAction Stop
}
Comments
Post a Comment