Thursday, March 19, 2015

Creating SharePoint 2013 Develpoment Environment on Azure

This blog shows how to create a SharePoint 2013 development environment on Azure.
In here I used a virtual network and two virtual machine one for  active directory and  other one for SharePoint and SQL installation.To make this environment only you have to follow the following steps.
  1. Create a Virtual Network.
  2. Provision a virtual machine to run the domain controller and DNS server roles.
  3. Install Windows Server Active Directory.
  4. Add the basic installation accounts
  5. Set the DNS server for the Azure virtual network.
  6. Provision a virtual machine to run the SharePoint and SQL
  7. After virtual machine is provisioned, sign in and join it to the domain.
  8. SQL Server 2012 Installation.
  9. Windows server 2012 configuration.
  10. SharePoint 2013 configuration.

Create a Virtual Network


  1. Sign in to the Azure Management Portal.
  2. Create a virtual network. Click Networks > Create a virtual network. Use the values in the following to complete the wizard.

    Provision a virtual machine to run the domain controller and DNS server roles

    1. In the Azure Management portal, click New > Compute > Virtual Machine > From Gallery and use the following values.
    • Virtual Machine Name: Type a single label
    • New User Name and the password: Type the name of a user. This user will be a member of the local Administrators group on the VM.
    • Cloud Service: Choose Create a new cloud service.
    • Cloud Service DNS Name: Specify a globally unique name
    • Region/Affinity Group/Virtual Network: Specify the virtual network name.
    • Storage Account: Choose Use an automatically generated storage account.
    • Select Install the VM Agent and any other extensions you need.


    Install Windows Server Active Directory

    Once you created the VM then you have to install the AD and configure it.
    1. Open Server Manager and click ‘Manage’ on the top right corner to add Roles and Features.
    2. Select the role-based or feature-based installation.
    3. Select the server you want to use as a Domain Controller.
    4. Click to add ‘Active Directory Domain Services’. You don’t have to check ‘Domain Name System (DNS) server’ right now since it’s also promoted later.
    5. Add required features and skip the feature selection dialog.
    6. Click install and wait until the installation finished. Don’t close the dialog.
    7. A link will be displayed to promote the server to a domain controller. Click the link.
    8. Select to create a new forest and enter a root domain name.
    9. Make sure ‘Domain Name System (DNS) server’ is checked and enter a restore password.
    10. Skip the DNS Options and use the specified NetBIOS domain name.
    11. Use the specified locations for AD DS database, log files and SYSVOL. Click next to review your options.
    12. Click install and wait until you are required to reboot your server. Click on more.

      Add the Basic Installation Accounts

      You need to create at least the following domain accounts in Active Directory to successfully install SharePoint 2013.
      • SQL Server Service Account - sqlsvcacc
      • SharePoint Setup Administrator- spAdmin
      • SharePoint Farm Account -spFarm
      To do this,
      1. Open Server Manager and click ‘Tools’ on the top right corner and click on Active Directory Users and Computers.
      2. Under domain name you created,click right on Users.Then New > User.
      3. Then add the above three basic accounts as follows.


      Set the DNS Server for the Azure Virtual Network.


      1. Click Virtual Networks, double-click the virtual network you created and     click Configure.
      2. Under DNS servers, type the name and the IP of one of the VMs that runs the DC/DNS server role and click Save
      3. Select the VM and click Restart to trigger the VM to configure DNS resolver settings with the IP address of the new DNS server.

      Provision a virtual machine to run the SharePoint and SQL

      1. Create the Virtual Machine like earlier by choosing Windows Server 2012 Data centre image or  Visual Studio 2013 gallery image(In which already installed SharePoint,SQL and Visual Studio under msdn).
      2. Select A4 (8 Cores and 14GB Memory) as the machine size and virtual network you created above as the region.

      After virtual machine is provisioned, sign in and join it to the domain

      1. In Server Manager, click Local Server > WORKGROUP > Change
      2. Then select Domain and type the name of domain.
      3. Provide credentials of a domain user, and then restart the VM to complete the domain join.

      SQL Server 2012 Installation


      If you are using a virtual machine in which SQL Server installed,then no need to worry about the this.Otherwise follow the steps below link given.                            


      Windows server 2012 configuration

              If you are using a virtual machine in which Windows Server installed,then no need to worry about the this.Otherwise follow the steps below link given.
              http://sharepoint-tutorial.net/post/2012/07/16/install-sharepoint-2013-windows-server.aspx


              SharePoint 2013 configuration

              Before installing the SharePoint make sure you are logged in SharePoint administrator account.
              1. Run the SharePoint 2013 configuration wizard.
              2. Click Next and Select to create new farm account.
              3. Enter the SQL Server and specify  the database and the farm account details
              4. Specify the port number for the central administrator database(as you wish).
              5. Review your settings and start the installation.
              6. Once istallation is done,you can open the central administrator.

              Since we are using virtual machines within a virtual network we have to use static IP addresses. In my next post will be described this.

              Static IP Addresses with in a Virtual Network

              As long as the virtual machines are only shut down from within the virtual machines themselves they will maintain this IP address.But this is not same when the  virtual machines are shut down through PowerShell or the management portal.
              Here we are talking how to maintain  the internal IP address without a change.

              Suppose we have two virtual machines within a virtual network.

              Name                              IP                          Subnet
              VM1                          10.0.0.4                          subnet
              VM2                          10.0.0.5                          subnet

              Once a virtual machine is stopped(de-provisioned), at next boot time it will go through the same process to find the first available IP address in the subnet.

              What this means is without an alternative method of setting the IP address you are responsible for starting a set of virtual machines in the correct order to ensure their IP addresses are set.

              For example, if stop VM1 and VM2 and then start them in this order: VM2,VM1 the IP addresses have completely switched on like below.

              Name                              IP                          Subnet
              VM1                          10.0.0.5                          subnet
              VM2                          10.0.0.4                          subnet

              To solve this problem, specify the IP address for each virtual machine in an update.

              For that first you have to download the Microsoft Azure PowerShell Microsoft Azure PowerShell (Under Command Line Tools> Windows PowerShell>Install) and install it in your machine.

              Then run the following commands.
              • Add-AzureAccount  In here you should add your azure account using pop up windows.
              • Make sure your ID,subscription details is correct.to change the subscription plan use Select-AzureSubscription
              • Before assigninig the IP address you should shutdown the both machines.
                        Get-AzureVM -ServiceName vm1servicename | Stop-AzureVM -Force                     
                        Get-AzureVM -ServiceName vm2servicename | Stop-AzureVM -Forc
              • Then update the IP addresses one by one.                                                                 $vm = Get-AzureVM -ServiceName "vm1servicename" -Name vm1                         Set-AzureStaticVNetIP -IPAddress 10.0.0.4 -VM $vm                                               Get-AzureStaticVNetIP -VM $vm
                         $vm = Get-AzureVM -ServiceName "vm2servicename" -Name vm2 
                         Set-AzureStaticVNetIP -IPAddress 10.0.0.5 -VM $vm

                         Get-AzureStaticVNetIP -VM $vm




              Bind SharePoint list field names in to Dropdownlist/Checkbox

              Suppose  that you have a list and  you created some fields(columns) in that list.Then you need to display these columns in a visual web part when the page is loading.To do this just use  below code in your page_load method in the visual webpart project. 


              Display  columns which you created.
               protected void Page_Load(object sender, EventArgs e)  
                   {  
                     SPWeb spweb = SPContext.Current.Web;  
                     SPList List = spweb.GetList("Type url for the list");  
                     SPFieldCollection spfieldcollection = List.Fields;  
                     ListItemCollection ListColumnNames = new ListItemCollection();  
                     if (spfieldcollection.Count != 0)  
                     {  
                       foreach (SPField field in spfieldcollection)  
                       {  
                         if (!field.FromBaseType)  
                         {  
                           ListColumnNames.Add(new ListItem(field.Title));  
                         }  
                       }  
                     }  
                     dropdowncontrol.DataSource = ListColumnNames;  
                     dropdowncontrol.DataBind();  
                   }  
              

              Display all columns

               protected void Page_Load(object sender, EventArgs e)  
                   {  
                     SPWeb spweb = SPContext.Current.Web;  
                     SPList List = spweb.GetList("Type url for the list");  
                     SPFieldCollection spfieldcollection = List.Fields;  
                     ListItemCollection ListColumnNames = new ListItemCollection();  
                     if (spfieldcollection.Count != 0)  
                     {  
                       foreach (SPField field in spfieldcollection)  
                       {  
                           ListColumnNames.Add(new ListItem(field.Title));    
                       }  
                     }  
                     dropdowncontrol.DataSource = ListColumnNames;  
                     dropdowncontrol.DataBind();  
                   }  
              






              For the checkboxlist you change "dropdowncontrol" in to "checkboxlistcontrol".

                checkboxlistcontrol.DataSource = ListColumnNames;  
                checkboxlistcontrol.DataBind();