Powershell ile yazmış olduğum Azure üzerinde storage account oluşturmanızı sağlayan fonksiyon aşağıdaki gibidir. Azure hesabınıza bağlandıktan sonra ilgili fonksiyonu kullanabilirsiniz.
Function New-StorageAccountMenu {
<#
.Synopsis Create Storage Account with Powershell function
.EXAMPLE New-StorageAccountMenu
#>
Write-Host " "
Write-Host "Building Azure Storage Account" -ForegroundColor Green
#Ask to input the Azure datacenter to use:
do{
Write-Host ""
Write-Host "[1] West Europe"
Write-Host "[2] North Europe"
Write-Host "[3] East US 2"
Write-Host "[4] East US"
Write-Host "[5] Central US"
Write-Host "[6] South Central US"
Write-Host "[7] West US"
Write-Host "[8] Southeast Asia"
Write-Host "[9] East Asia"
Write-Host "[10] Japan West"
Write-Host -NoNewline "Enter the number (1 - 10) of the datacenter location to use: " -ForegroundColor Magenta; [int]$locationnumber=read-host
If ($locationnumber -lt 1 -or $locationnumber -gt 10 ) {
Write-Host "You did not enter a (1-10) digit number - please check your number" -ForegroundColor Red
}}while($locationnumber -lt 1 -or $locationnumber -gt 10)
Switch ($locationnumber) {
1{ $location = "West Europe" }
2{ $location = "North Europe" }
3{ $location = "East US 2" }
4{ $location = "East US" }
5{ $location = "Central US" }
6{ $location = "South Central US" }
7{ $location = "West US" }
8{ $location = "Southeast Asia" }
9{ $location = "East Asia" }
10{ $location = "Japan West" }
default {$location = "West US" }
}
Write-Host ""
Write-Host "Your datacenter location is: " $location -ForegroundColor Green
Do {
Write-Host ""
Write-Host -NoNewline "What is the first 6 character of your CompanyName (e.g. Adatum): " -ForegroundColor Magenta; $lcnumber=read-host
If ($lcnumber.Length -ne 6) {
Write-Host "You did not enter 6 character of your CompanyName " -ForegroundColor Red
}
} While ($lcnumber.Length -ne 6) #Make sure enters a 6 Company char
Do {
Write-Host ""
Write-Host -NoNewline "What is your 2 digit suffix number, including any leading zero (e.g. 09): " -ForegroundColor Magenta; $stnumber=read-host
If ($stnumber.Length -ne 2) {
Write-Host "You did not enter 2 digit suffix - please check your suffix number" -ForegroundColor Red
}
} While ($stnumber.Length -ne 2) #Make sure suffix enters a 2 digit number
$fullsuffix = $lcnumber + $stnumber
Write-Host " "
Write-Host "Your unique suffix is: " $fullsuffix -ForegroundColor Green
Write-Host " "
Start-Sleep -Seconds 5
try{
New-AzureStorageAccount -StorageAccountName $fullsuffix.ToLower() -Location $location | Out-Null
Write-Host " "
Write-Host "Storage Account has been created" -ForegroundColor Green
Write-Host " "
Write-Host "Storage Account name:$fullsuffix" -ForegroundColor Green }
catch{
Write-Host "Storage Account couldn't create" }
}