Home Ask Login Register

Developers Planet

Your answer is one click away!

Oscar Foley February 2016

How to specify DNS name (Domain Name) prefix in Azure ASM?

This is the script I use to create a classic (ASM) VM in Azure

[switch] $Help = $false,                                                      
$azureUsername ,                                                              
$azureSubscriptionName ,

#Preparation steps
$startTime = Get-Date
Write-Host -ForegroundColor Cyan "This script will create a classic VM '$VMName'"
Write-Host "Script started ($startTime)"
DetectPowershellVersion 4
$azurePassword = $azurePassword | ConvertTo-SecureString -asPlainText -Force
$azureCredentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $azureUsername,$azurePassword
Disable-AzureDataCollection -WarningAction SilentlyContinue

Write-Host -ForegroundColor Cyan "Step 1: Logging in to Azure..."
Add-AzureAccount -credential $azureCredentials | Out-Null
Write-Host "Logged in."

Write-Host -ForegroundColor Cyan "Step 2: Selecting subscription..."
Select-AzureSubscription -SubscriptionName $azureSubscriptionName -Current
New-AzureStorageAccount -StorageAccountName $azureStorageAccountName -Label $azureStorageAccountName -Location "North Europe" -ErrorAction SilentlyContinue
Set-AzureSubscription -SubscriptionName $azureSubscriptionName -CurrentStorageAccountName $azureStorageAccountName
Write-Host "Selected Subscription = $((Get-AzureSubscription -Current).SubscriptionName)"
Write-Host "Selected Storage Account Name = $azureStorageAccountName "

Write-Host -ForegroundColor Cyan "Step 3: Locating VMImage subscription..."
$VMImage = (Get-AzureVMImage | Where { $_.Label -like "$($VMImageName)*"        


Michael B February 2016

In your #7 Provision VM! you have

New-AzureService -ServiceName $AzureResourceGroupName `
                 -Location "North Europe" `
                 -ErrorAction SilentlyContinue `
                 -WarningAction SilentlyContinue

Changing $AzureResourceGroupName to TestOranges will give you the result you seek

The problem you are having is due to the fact that ASM doesn't use resource groups in the same way that ARM does. (it's use of them is somewhat inconsistent -it largely does its own thing with the names of)

Post Status

Asked in February 2016
Viewed 3,397 times
Voted 4
Answered 1 times


Leave an answer

Quote of the day: live life