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

param(
[switch] $Help = $false,                                                      
$azurePassword,                                                               
$azureUsername ,                                                              
$azureSubscriptionName ,
$VMImageName,                                                                 
$azureStorageAccountName,
$AzureResourceGroupName,
$VMSize,                                                                      
$VMName,
$VMAdministratorUsername,
$VMAdministratorPassword,
$VNetName,
$VNetSubnetName
)

#Preparation steps
Clear-Host
$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

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

#2
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 "

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

Answers


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

Search




Leave an answer