Partager via


Creating a Lab on Windows Azure

Editor’s note: The following post was written by SharePoint Server MVPInderjeet Singh Jaggi

Creating a Lab on Windows Azure

Recently when I got access to Azure I wanted to create my lab on Azure which took me days to figure out the process. It is similar to what we do on our Hyper V machines but a bit complex in nature because we are working on cloud

We follow the same process on our local machine to create a Lab environment but normally we are short of resources like  Disk Space, RAM, CPU which is the taken care by Azure. Biggest dis-advantage for our local system environment is when you buy these resources, you don’t use it all the time which we have already paid for. In Azure we pay only when you use it.

Today we will understand how we can create our own Lab environment on Windows Azure. The whole process is lengthy to explain so I have divided it in 8 different parts listed below. Hope you will enjoy learning it.

  • Connect to your Azure Subscription using PowerShell.
  • Create a Virtual Network in Azure
  • Create a server on Azure in the Virtual Network
  • Create a new domain
  • Update Domain setting on Virtual Network and bind it to Private IP on DC
  • When creating a new server it should be part of this domain
  • Install SQL, SharePoint. etc. labs as part of this domain
  • Troubleshoot common issue during this process

 

  • Connect to your Azure Subscription using PowerShell

You cannot create your lab with just Azure User Interface. It’s said that “Well planned is half done”. So let’s plan and prepare our self with Azure PowerShell.  Go to below link and download Microsoft Web Platform installer.

  1. You can use it download and install Azure PowerShell

https://go.microsoft.com/fwlink/p/?linkid=320376&clcid=0x409 

 

 

 2. Once the PowerShell is downloaded and installed, we will get below message

 

 3. Now we will download the Azure Setting file to connect to our Azure subscription. In the Azure PowerShell, type below command.

Get-AzurePublishSettingsFile

 

 4. Once you login to your Azure website, you will get a file named "Visual Studio Premium with MSDN-date-credentials.publishsettings".

 

Note: File name may change based on your subscription. Save it to a secure location. This file contains secure credentials and additional information about subscriptions that you can use in your Azure environment.

 5. Now Import the Azure Settings file to PowerShell. Run "Import-AzurePublishSettingsFile" and then type path of the file we just downloaded as shown in below image.

 

 6. To check Subscription details run below command

Get-AzureSubscription

 

  • Create a Virtual Network in Azure.

Now let’s create a Virtual Network in Azure like we do in our Hyper-V servers. We need this Virtual network so that all the new and old Machine are in same IP range and can communicate with each other. You don’t need to be a Networking expert to do so. Just follow steps mentioned below.

 

  1. Login to your Azure Subscription Portal site https://manage.windowsazure.com
  2. Select “Network” from left hand menu > Select “New” on left bottom corner
  3. Now in the Menu select “Custom Create”
  4. Now type the network name and select the data center for that network(note all computers should be in the same datacenter)

 

 5. For now we will keep this DNS server empty (We should have our Domain controller DNS IP here. Our DC is not yet created so we keep it blank). Click on Next

 

 6. On "Virtual Network Address Spaces", provide name of your network and Subnet count (I won’t have more than 256 machines so selected same). Click on “Add Subnet”. Click on Finish

 

 

Here we have our Virtual Network created. Note this Network will then be used while creating our Virtual Machine. The very first machine we will create is our Domain controller. Once the domain controller is created we will update it in DNS server records used above.

 

  • Create a server on Azure in the Virtual Network

If you have worked on Hyper-V or any other Virtual server environment, this process is pretty simple for you. Here we will create our Virtual Machines. First machine would be our Domain Controller also known as DC. This server manage DNS, AD Users, etc. and normally the 1st and most important server in a company.

  1. Login to your Azure Subscription Portal site https://manage.windowsazure.com
  2. Select “Virtual Machines” from left menu and select “Create a Virtual Machine”

 

 

3. Under “Virtual Machine” select “From Gallery”

 

 

4. On the Choose an Image screen select “Windows server 2012 R2” and select Next

5. Type a unique name for the Virtual Machine. Select a username and password which you will never forget.(Selected a Low configuration because I won’t be using it much)

 

 

6. Now we have the most important step in the process. Select the DEMONETWORK you created in Region/Affinity Group/Virtual Network. Make sure our Virtual network name is selected in Virtual Network Subnet. Click on Next.

 

 

7. Now Select Finish.

8. Once the Machine is created, you will get a Connect button at bottom of screen.

 

  • Create a new domain

Now let’s configure this server to be a Domain Controller. As discussed earlier Domain controller manage DNS, AD Users, etc. and are normally the 1st and most important server in a company.

 

  1. Login to your Azure Subscription Portal site https://manage.windowsazure.com
  2. Select Virtual Machine from left Menu
  3. Select the Virtual Machine we just created and click on Connect at bottom
  4. Now RDP to the Virtual Machine we created and click on Server Manager

 

 

5. Select Manager > Add Roles and Features

 

 

6. Select “Next” on Installation Type screen

 

 

7. Select “Next” on Destination Server screen

 

 

8. Check Box “Active Directory Domain servers”

 

 9. Click on “Add Feature” on pop-up screen

 

 10. Select the check box “Restart the destination server if required” > Click OK

 

 11. Once it is installed, Click on Close

 

 12. Open the Server Manager again, Click on Flag at top and select “Promote this server to a Domain Controller”

 

 13. Select "Add a New forest", type domain name

14. Type the DSRM password and click “Next” (Note: this is required when you try to recover your active directory)

 

 15. Now you will have to select your domain name. For example. Demo.com

16. The NetBIOS Name screen will remove .com and you will see only demo.

17. Select the Default location of installation and click “Next”

18. Click on “Install”

 

 19. Once the Computer is restarted, your Domain Controller would be ready.

Note: From now on when you logon to server you need use your domain name along with username we just created to authenticate to server. Example: demo\user1

 

  • Update Domain setting on Virtual Network and bind it to Private IP on DC

So far we have created a Virtual Network and a Domain controller in that Virtual network. I hope this process was simple enough for you to follow. It is very important that Domain Controller and DNS have a static IP address so that all other machines know whom to contact to authenticate and resolve computer name. Now we need to make sure that our domain controller has a static IP address and then assign it to DNS on Virtual Network. To do so we will follow below steps:

 

  1. Login to your Azure Subscription Portal site https://manage.windowsazure.com
  2. Select Virtual Machine from left Menu
  3. Select the Virtual Machine we just created and click on Connect at bottom
  4. Now RDP to the Virtual Machine we created as a Domain Controller
  5. Open Windows PowerShell and run command “IPConfig”. Make a note of IP address
  6. Click on Start and Open DNS manager. Expand Computer name > Forward Lookup Zone > Demo.com > Make sure Ipconfig and DNS has same IP address.

 

 7. Make sure you are connected to Azure PowerShell account by following steps we discussed in section “Connect to your Azure Subscription using PowerShell”

8. Run command “Get-AzureVM”. You should be able to see your Azure Virtual Machine name, make a note of same

 

 9. Run below command in Azure PowerShell

Get-AzureVM -ServiceName “Service name from Get-AzureVM command” -Name “name from Get-AzureVM command”| Set-AzureStaticVNetIP -IPAddress "10.0.0.4" | Update-AzureVM

 10. Now the system will get restarted and a Static IP will be assigned to same. We need to update the same IP in the Virtual Network we created in Azure.

11. Login to your Azure Subscription Portal site https://manage.windowsazure.com

12. Select “Network” from left pane > Select the “Demo Network” we created > Click “Configure” on top.

13. Update the IP Address of Domain Controller and Domain name. E.g. demo 10.0.0.4. Click on Save at bottom to save these changes

 

  • When creating a new server it should be part of this domain

We are nearly done with our Domain related activities. Now we need to make sure that all the Virtual Machines we create are part of same Active Directory. This will help us to manage the server and users in domain. In number of Demos we need a domain (AD), so we have met the most important pre-requisites.

 

  1. You need to copy below script into a notepad and save it as join.PS1

///// SCRIPT START HERE   ////

 

$domainName = "type domain name here e.g. demo.com. It should be in quotes"

$username = "type domain\username e.g. demo\user1. It should be in quotes"

$password = "type password of above user e.g. 213@jjj. It should be in quotes"

$securePass =  ConvertTo-SecureString $password -AsPlainText -Force

$cred = New-Object System.Management.Automation.PSCredential($username, $securePass)

Add-Computer -DomainName $domainName -Credential $cred -Restart –Force

////// SCRIPT END HERE   ////

 

2. Login to your Azure Subscription Portal site https://manage.windowsazure.com

3. Select “Virtual Machines” from left menu and select “Create a Virtual Machine”

 

 4. Under “Virtual Machine” select “From Gallery”

 

 5. On the Choose an Image screen select “Windows server 2012 R2” and select Next

6.   Type the Machines necessary details like Hardware configuration, Machine name, username and password

 7.Now we have an important step in the process. Select the DEMONETWORK you created in Region/Affinity Group/Virtual Network. Make sure our Virtual network name is selected in Virtual Network Subnet. Click on Next

 

 8. Now comes the most important step, we need to select Custom Script on this page and select the Join.ps1 script we just created. Click Finish

 

 9. You will observer that your machine will reboot during the initialization process.

10.  Now when the machine is created, Open Server Manager and you will observe it is already part of Demo domain. On the domain controller in “Active Directory users and computers” you should be able to see the newly added

 

 

Note: In some rare scenario, the new computer may not get added to the domain. In that case, please run above PowerShell command line by line and the computer would be added to domain.

 

  • Install SQL, SharePoint. etc. labs as part of this domain

Once we are confirmed using script we are able to add new Virtual Machine to domain, we can use the ready to use SharePoint, SQL, etc. VM’s as part of our Lab environment. Let’s see an example of SharePoint server.

  1. Login to your Azure Subscription Portal site https://manage.windowsazure.com
  2. Select “Virtual Machines” from left menu and select “Create a Virtual Machine”

 

 3. Under “Virtual Machine” select “From Gallery”

 

 4. On the Choose an Image screen select SharePoint server 2013 Trial. This trial works for 180 days.

 

 5. Type the Machines necessary details like Hardware configuration, Machine name, username and password

6. Now we have an important step in the process. Select the DEMONETWORK you created in Region/Affinity Group/Virtual Network. Make sure our Virtual network name is selected in Virtual Network Subnet. Click on Next

 

 7. Now comes the most important step, we need to select Custom Script on this page and select the Join.ps1 script we just created. Click Finish

 

 8. Now you can see that even SharePoint server is ready within few minutes

9. Advantage here is that you have a single credential stored on Active directory using which you manage all the Virtual Machine and work on your lab.

10. Below you can see that I have created SQL server, SharePoint server and started using them in just couple of minutes.

 

 

 

  • Troubleshoot common issue during this process

Issue 1

Error message: No current subscription has been designated. Use Select-AzureSubscription -

Current <subscriptionName> to set the current subscription

 

Command : No current subscription has been designated. Use Select-AzureSubscription -
Current <subscriptionName> to set the current subscription.
At line:1 char:1
+ Test-AzureStaticVNetIP –VNetName test –IPAddress 11.0.0.1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Test-AzureStaticVNetIP], ApplicationException
+ FullyQualifiedErrorId :
System.ApplicationException,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.TestA
zureStaticVNetIPCommand

 a. Did some research and found that we need to connect to Azure subscription and then run these command. To do so we need to download and install Azure PowerShell. Copy paste below URL on your browser and install the Web Platform Installer. This will give you option to download Azure PowerShell.

https://go.microsoft.com/fwlink/p/?linkid=320376&clcid=0x409

 

 b. Once the PowerShell is downloaded and installed, we will

 

 c. Now we will download the Azure Setting file to connect to the azure server. In the Azure PowerShell, type below command.

Get-AzurePublishSettingsFile

 

 d. Once you login to your Azure website, you will get a file named "Visual Studio Premium with MSDN-date-credentials.publishsettings". Save it to a secure location. This file contains secure credentials and additional information about subscriptions that you can use in your development environment.

 e. Now Import the Azure Settings file to PowerShell. Run "Import-AzurePublisingSettingsFile" and then type path of the file we just downloaded as shown in below image

 

 

 f. To check Subscription details run below command

Get-AzureSubscription

 

 g. Now the command completed successfully.

 

 

Issue 2: When you logon to some server using Domain account, you cannot access the pre-installed software like SQL server.

 

Solution:

When the VM is created, it is created account you specify using Azure VM creation screen and then added to domain. So by default other account don’t have access to the application installed during VM creation. You have to 1st Logon to the server using Azure VM account give appropriate permission to domain account and then use it.

 About the author

Inderjeet Singh has around 10+ years of professional experience in SharePoint administration. He has good knowledge of migration, implementation and design architecture of SharePoint servers. He was amongst the 1st few contributor who hosted a custom App on SharePoint Store which was later removed. He worked on all versions of SharePoint (From 2001 to 2013). I write Sharepoint and azure articles on my website 

 

About MVP Monday

The MVP Monday Series is created by Melissa Travers. In this series we work to provide readers with a guest post from an MVP every Monday. Melissa is a Community Program Manager, formerly known as MVP Lead, for Messaging and Collaboration (Exchange, Lync, Office 365 and SharePoint) and Microsoft Dynamics in the US. She began her career at Microsoft as an Exchange Support Engineer and has been working with the technical community in some capacity for almost a decade. In her spare time she enjoys going to the gym, shopping for handbags, watching period and fantasy dramas, and spending time with her children and miniature Dachshund. Melissa lives in North Carolina and works out of the Microsoft Charlotte office.

Comments

  • Anonymous
    February 09, 2015
    Detailed post and a good one :) Being a PowerShell enthusiast, I would have loved to see more of PowerShell stuff in here e.g the alternate cmdlets that can be used to deploy a VM (New-AzureVM) , use of PSRemoting over https to the VM to deploy a DC etc. Maybe next post ;)

  • Anonymous
    February 11, 2015
    This is an excellent article, and perfect for my purposes!  I have setup several different environments in the Azure cloud for testing and development on different projects.  I used to do all of this on a set of local Hyper-V servers, and that works well.  Overall, I found the Azure process to be simple and intuitive, though this article points out a lot of differences between on-prem and hosted configurations.  I also use TechNet Virtual Labs (technet.microsoft.com/.../bb467605.aspx) if I just need to access a specific product (like the entire System Center suite) or want a guided tour of something I don't use very often. Again, thanks for the work you put into this excellent post!

  • Anonymous
    March 03, 2017
    The comment has been removed