Skip to content

Instantly share code, notes, and snippets.

@astaykov
Created March 27, 2014 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save astaykov/9821334 to your computer and use it in GitHub Desktop.
Save astaykov/9821334 to your computer and use it in GitHub Desktop.
Azure VM - AD/DC with DNS Server and a Client
# first authenticate using your Azure Active Directory credentials
Add-AzureAccount
# then list all the subscriptions to get the name
Get-AzureSubscription
# now set the subscription context as well as default storage account that
# will be used for rest of the operations
# note, the account has to be created in the same Affinity Group as the Virtual Network !!
Set-AzureSubscription "[YOUR Subscription Name]" -CurrentStorageAccountName "[azurestorageaccount]"
# The domain controller
# Important: the -DnsSettings affects the entire Cloud Service, not just the deployed VM !!
$adminPassword = "SuperCoolPassword123!"
$images = Get-AzureVMImage | where {$_.Label -match "Windows Server 2012 R2"}
$vmImage = $images[7]
$dnsServerLocal = New-AzureDns –Name "NameResolver" –IPAddress "127.0.0.1"
New-AzureVMConfig -Name "NameResolver" -InstanceSize Large -ImageName $vmImage.ImageName ` |
Add-AzureProvisioningConfig –Windows –Password $adminPassword -AdminUsername "[admin_user_name]" ` |
Set-AzureSubnet -SubnetNames "NSNet" ` |
Set-AzureStaticVNetIP -IPAddress 192.168.30.4 |
New-AzureVM –ServiceName "nameresolver"-VNetName "VNET-DEMO-WE" -DnsSettings $dnsServerLocal
# The client
# Because of the DNS settings, place the VM in other Cloud service
$adminPasswordClient = "SuperCoolPassword123!"
$images = Get-AzureVMImage | where {$_.Label -match "Windows Server 2008 R2"}
$vmImage = $images[7]
New-AzureVMConfig -Name "resolvetester" -InstanceSize Small -ImageName $vmImage.ImageName ` |
Add-AzureProvisioningConfig –Windows –Password $adminPasswordClient -AdminUsername "[admin_user_name]" ` |
Set-AzureSubnet -SubnetNames "ClientsNet" ` |
New-AzureVM –ServiceName "resolvetester"-VNetName "VNET-DEMO-WE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment