Build Domain Controller With AD Tenants In Azure

“Infrastructure as code” is the true power of Microsoft Azure Cloud. Here, I sketched a single file used to install a domain controller in Microsoft Azure with the provision of an Azure AD Tenant. You need to define all parameters first. All AD Groups, AD Test users, AD Members, and AD OUs are present in attached .csv files. I passed the example parameters in script. Script will do the following in sequence shown below, based on your parameters

  • Storage Account
  • Virtual Network and Subnet
  • Cloud Service
  • Virtual Machine
  • Domain and Tenant

Since I am in New Zealand, I mentioned my closest Microsoft Data Center location "Australia East" in script everywhere. Place all files in one folder. For example, in my case, all files are residing at location in folder C:\DC\.

DC is folder name here. All files with given names are attached

  • File to create domain controller
    DomainController.ps1

  • File to create VNet and Subnet
    CreateVNetSubNet.xml

  • File to create AD Groups
    AD_Groups.csv

  • File to create AD members
    AD_Members.csv

  • File to create AD OUs
    AD_OUs.csv

  • File to create AD Users
    AD_Users.csv

Here are the steps to execute the script with mentioned files.

  1. Open PowerShell ISE with Administrator Account.

  2. Add-Azure Account, as shown below.

    Azure

  3. Pass Azure Account Credentials in prompt window.

    Azure

  4. Run command Get-AzureSubscription in order to see if subscription is valid or not.

    Azure

  5. Select the DomainController.ps1 from location C:\DC\ and open in PowerShell.

    Azure

  6. Run the script and it will look like below. Note that the script has started  executing in sequence.

    Azure

  7. Here, you can see the progress.

    Azure

  8. After completion of the above, the following will be created.

    Azure

  9. Click on VM i.e "MyTestVMforAD".

    Azure

  10. Press "Connect" to take session.

    Azure

    Azure

  11. After log-in, go to server administrative tools and click "Active Directory Users and Computers".

    Azure

  12. WOW, domain controller has been provisioned and users imported.

    Azure