Thursday, September 18, 2014

Setting up an SP2013 VM on Azure, with a GUID-less DB

      1. Critical Path Training produces a number of excellent training courses, books, and free resources.   If you haven't checked out their Inside SharePoint 2013 book, you definitely should.  It's a pretty comprehensive guide to what Developers need to know (initially) to do SP2013 Development.

        I typically build their VM when I first start using the next version of SharePoint and often make it my baseline for general development.   This year however I've decided to spice it up a bit and go for an install without the Configuration Wizard and a GUID-less database instance, per Todd Klindt/Shane Young's book because their guide is more close to an enterprise level configuration.  I also wanted install and configure it in Azure, so I can get to it wherever I am (and free up some SSD space on my PC).

        The Critical Path VM guide can be downloaded here.  You'll need a (free) account to download the guide.  I suggest you read through the guide to get a good sense of what you'll be doing (and how much goes into building a VM - the key reason why I want it built and backed up in the cloud, redoing this is a time consuming process.)  After you've read the guide, if you want to build it in Azure, with GUID-less DBs,  then hopefully my experience will help you.

        The Critical Path VM guide version I used is Version 3.0, written by Gary Lapointe (who is a Powershell master and also wrote an excellent book for SP2010).  I put items in bold text when I'm either straying from or returning to the Critical Path guide (hereafter referred to as the CP Guide).



        1. Log in to Azure
        2. Click "Networks" and create a new Virtual Network, you just have to give it a name, don't worry about the DNS, VPN, or subnet stuff
        3. Click Virtual Machines and create a new Windows Server 2012 R2 Datacenter VM (from the Gallery)
          1. Give it a name
          2. Choose the A4 "Size" and create a new user (Admin and Administrator are reserved, so I use Local_Admin)
          3. On the next page, you can either create a new cloud service or use an existing one.   Your choice
          4. For the Region, choose the Virtual Network you created in step 2
          5. Leave storage and Availability sets as thConeir default, then choose the next arrow.
          6. Remote desktop to the new VM.   Click Start > Run > mstsc and click enter and enter in the DNS name for your new VM (Listed in the table of your VMs in Azure)
          7. NOTE:   The Critical Path guide suggest creating 2 Networks/NICs for your VM but as far as I was able to tell this is not yet supported, so you have to go with only one.
        4. At this point you can get back to the CP guide, just find the section where the installation of Windows finishes up.
          1. You can skip the rename the PC part, so long as you like the name you set up in Azure initially
          2. Do the Disable Enhanced security Config (ESC) steps.
          3. Do the Firewall Steps
          4. Skip the Remote Desktop step (you're already remoted in...)
          5. Do the step where you set the Admin password to never expire
          6. Skip the networking section (both internal and external) and simply test your network connection by opening IE and browsing to an external site like www.bing.com
          7. Enable the Desktop Experience per the guide (NOTE you'll need to click next a few times to get to the Features selection, the guide makes this seem like you can go straight to Features).
          8. Do the windows updates per the guide
          9. Skip the Windows Activation (should already be activated)
          10. Do the Active Directory Configuration Task per the CP guide
          11. Start the SQL Server Installation
            1. Skip the DVD mouting directions and just open up IE and download the SQL Server 2012 R2 ISO from MSDN, then open the downloaded ISO and it should mount as your E: drive
            2. Click the setup.exe file and then resume the Critical Path guidance
            3. After SQL is installed:
              1. Continue with the SQL Configuration per the document
              2. [optional, but recommended] Set the Max Degrees of Parallelism on SQL to 1.]
                1. On your VM start SQL Management Studio and connect to your SharePoint SQL Instance (should be your local server in this case)
                2. Once connected to the SQL Instance right click on the Instance name and choose "Properties" from the context menu, then choose the "Advanced" page.
                3. On the Advanced page, scroll down to the Parallelism category and set Max Degrees of Parallelism to 1 (from the default of 0).  Then click OK.
              3. You can optionally install the AdventureWorks data, but if you're new to SP and intend to mess around with BI stuff, it's probably a good idea.  (note you can do this later if you wish)
          12. Continue with the file downloads
          13. Continue with creating the Service accounts with Script01 (for DNS) and Script02 (for creating users)
          14. Continue by installing the SharePoint prerequisites
          15. Continue with SharePoint installs
          16. Continue with addition 
            1. Install the C++ redistributable package
            2. Download the Web Platform installer
              1. Install the Service Bus 1.0 and CU
              2. Install the Workflow Manager 1.0 Refresh
          17. At this point you now (may) want to stop using the guide so we can do an install without the configuration wizard.  I'll be using the guidance that was provided by Todd Klindt/Shane Young's book in chapter 3 for this.
          18. Do the Initial Setup of farm
            1. Open the SharePoint Management Shell as an Administrator (run as Administrator)
              1. Type the following command to set up the farm and Central Admin:
                New-SPConfigurationDatabase -DatabaseName SharePoint_Config -DatabaseServer YOURSERVERNAME -AdministrationContentDatabaseName SharePoint_Admin_Content
              2. You'll first be prompted for a username and password.  Enter your SP_Farm account here (if you followed the CP guidance your password is "Password1")
              3. You'll be prompted to provide a farm passphrase.   To stay consistent with the CP Guidance, use "Password1"
              4. You'll wait a few minutes for the command to finish running (it seemed like about 10 for me, so be patient).
            2. Next, launch the SharePoint Configuration Wizard.
              1. You should be able to just click next through this, but make sure you choose a port number that you can remember.
              2. After the wizard completes you should be directed to Central Admin and asked if you want to participate in the customer experience program
          19. Set up your farm's Core Services
            1. On the first page it asks you to either "Start the Wizard" or "Cancel" (you'll configure things yourself).  We want to configure everything ourselves and use Powershell whenever it's the better option, so click "Cancel"
            2. Set up a few Managed Accounts
              1. Go to Security > General Security > Configure managed accounts
              2. Verify that SP_Farm is already listed as a Managed Account
              3. Set up your SP_Services (will be used as the app pool, service identity, etc for the Service Applications) account as a managed account
                1. Click Register Managed Account
                2. Enter in DOMAIN\SP_Services (where DOMAIN is your domain WINGTIP if you've stuck with CP) and then enter the Password
                3. Ignore everything else and click OK
                4. Verify that you see SP_Services listed in the Managed Accounts list
              4. Repeat step 3, above, for SP_Content (will be used as the app pool account for the content applications)
            3. Set up your service application pool
              1. New-SPServiceApplicationPool -Name "Default SharePoint Service App Pool" -Account [YOURDOMAIN\YOURSERVICEACCOUNT]
                where YOURDOMAIN is your domain (duh, in the CP guide it's WINGTIP) and your service account is the account you created for you SharePoint service applications (SP_Services if you're following the CP guide).
              2. Once you execute this command, you may want to see the new app pool in IIS, but don't bother because you wont see it until you associate a service application with this app pool.
            4. Provision the state service by executing the following lines (press enter after each line)
              1. New-SPStateServiceApplication -Name "State Service Application"
              2. Get-SPStateServiceApplication | New-SPStateServiceApplicationProxy -defaultproxygroup
              3. Get-SPStateServiceApplication | New-SPStateServiceDatabase -Name "State_Service_DB"
              4. Get-SPDatabase | Where-Object {$_type -eq "Microsoft.Office.Server.Administration.StateDatabase"} | Initialize-SPStateServiceDatabase
            5. Provision Usage and Health Data by executing the following lines (press enter after each line)
              1. New-SPUsageApplication -Name "Usage and Health Data Collection"
              2. $proxy = Get-SPServiceApplicationProxy | where {$_.TypeName -eq "Usage and Health Data Collection Proxy"}
              3. $proxy.Provision();
            6. The CP Guide  suggests turning on these services via the Wizard, I've used strikethrough the ones we configured already in the previous steps (then I'll talk about how to configure the remaining ones).  If you don't feel like you need to turn on some of the services right away, feel free to skip those steps.
              1. App Management Service
              2. Business Data Connectivity Service
              3. Excel Services
              4. Machine Translation (I'm skipping this one because I don't think I'll need it for a while)
              5. Managed Metadata
              6. PowerPoint Conversion
              7. Secure Store
              8. State Service
              9. Usage and Health Data Collection
              10. Visio Graphics Service
              11. Word Automation Services
              12. Work Management Service Application - this Service App depends on the Search Service and the User Profile Service, so we'll be configuring those here as well so the order will actually be
                1. User Profile Service
                2. Search Service
                3. Work Management Service
              13. Workflow Service Application
            7. Set up the App Management Service.  This involves configuring the subscription service app, so we'll do this too.
              1. Setup up the Subscriptions Service App
                1. Open the SP Powershell and type the following (then press Enter)
                  $svcapp = New-SPSubscriptionSettingsServiceApplication -ApplicationPool "Default SharePoint Services App Pool" -Name "Subscriptions Settings Service" -DatabaseName "Subscriptions_Settings_Service_DB"
                2. Next type (and press enter):
                  New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $svcapp
                3. Then Type (and press enter):
                  Get-SPServiceInstance | Where-Object {$_.TypeName -eq "Microsoft SharePoint Foundation Subscription Settings Service"} | Start-SPServiceInstance
                4. After you run the above commands, you can verify everything is set up by confirming the Database was created (in SQL Management Studio) and verify the service is set up and started in Central Admin
              2. Next you need to configure DNS, this will set up your environment to be more (secure) like a production environment instead of using Subdomains off your current domain for your apps (which has the potential for CSS attacks)
                1. Open DNS Manager and create a new, Primary forward lookup zone, with all the defaults
                2. Give the zone name wingtipapps.com (or whatever name you want to use if you've strayed from the CP guide)
                3. Click next through the remaining screens, accepting the defaults, then click finish.
                4. Create a new CNAME by right clicking the domain you just created (wingtipapps.com) 
                  1. Put * for the Alias name
                  2. Put servername.wingtip.com. for your FQDN for target host
              3. Finally you can create the App Management Service in CA
                1. Go to CA > Manage Service Applications
                2. Click New on the Ribbon and choose "App Management Service" 
                  1. Give it the name "App Management Service"
                  2. Change the database name to App_Management_DB
                  3. Use an existing application pool and make sure your default Service App pool is selected
                  4. accept all other defaults and click OK at the bottom
                  5. If everything goes right you should see your App Management Service running in CA
                  6. The Service App will indicate it's started, but the Service actually isn't running until you go to "System Settings" > Manage Services On Server and click the start button on the Application Management Service line
            8. Next, let's configure BDC in CA
              1. Go to CA > Manage Service Applications
              2. Click New on the Ribbon and choose the BDC service
                1. Name it BDC 
                2. Remove the GUID from the end of the DB name
                3. Use the Existing Service App Pool
                4. Then click OK at the bottom
                5. Wait for the spinner to finish and you should see your BDC app in the Service Applications list
                6. The Service App will indicate it's started, but the Service actually isn't running until you go to "System Settings" > Manage Services On Server and click the start button on the BDC Service line
            9. Now for Excel Services
              1. Go to CA > Manage Service Applications
              2. Click New on the Ribbon and choose the Excel Services Application
                1. Name it Excel Services 
                2. Use the Existing Service App Pool
                3. Then click OK at the bottom
                4. Wait for the spinner to finish and you should see your Excel Services app in the Service Applications list
                5. The Service App will indicate it's started, but the Service actually isn't running until you go to "System Settings" > Manage Services On Server and click the start button on the Excel Calculation Services line
            10. Next is Managed Metadata
              1. Go to CA > Manage Service Applications
              2. Click New on the Ribbon and choose the Managed Metadata service
                1. Name it Managed Metadata Service 
                2. Name the DB "Managed_Metadata_DB"
                3. Use the Existing Service App Pool
                4. Then click OK at the bottom
                5. Wait for the spinner to finish and you should see your Managed Metadata Service app in the Service Applications list
                6. The Service App will indicate it's started, but the Service actually isn't running until you go to "System Settings" > Manage Services On Server and click the start button on the Managed Metadata Web Service line
              3. Now set your Managed Metadata Service to be the default storage location
                1. Go back to CA > Manage Service Applications
                2. Select the Managed Metadata Service Connection line (not the link itself or you'll jump to the wrong screen).  If you've done this right the line should highlight in light blue
                3. Click the Properties button on the ribbon
                4. Check the checkbox for "This service application is the default storage location for column specific term sets"
                5. Click OK
            11. Next is Secure Store
              1. Go to CA > Manage Service Applications
              2. Click New on the Ribbon and choose the Secure Store service
                1. Name it Secure Store Service 
                2. Remove the GUID from the end of the DB name
                3. Use the Existing Service App Pool
                4. Then click OK at the bottom
                5. Wait for the spinner to finish and you should see your Secure Store app in the Service Applications list
                6. The Service App will indicate it's started, but the Service actually isn't running until you go to "System Settings" > Manage Services On Server and click the start button on the Secure Store Service line.
              3. Finally, generate a key
                1. Under CA > Manage Service Applications click the link  for the Secure Store Application (the top one)
                2. On the ribbon, click "Generate New Key"
                3. type a good password twice.  (I used P@ssword1)
            12. Configure Visio
              1. Go to CA > Manage Service Applications
              2. Click New on the Ribbon and choose the Visio Graphics service
                1. Name it Visio Graphics Service
                2. Use the Existing Service App Pool
                3. Then click OK at the bottom
                4. Wait for the spinner to finish and you should see your Viso Graphics Service app in the Service Applications list
                5. The Service App will indicate it's started, but the Service actually isn't running until you go to "System Settings" > Manage Services On Server and click the start button on the Secure Store Service line.
            13. Configure Word Automation
              1. Go to CA > Manage Service Applications
              2. Click New on the Ribbon and choose the Word Automation service
                1. Name it Word Automation Service
                2. Use the Existing Service App Pool
                3. Check the checkbox to Add this service applcation's proxy to the farm's default proxy list.
                4. Then click OK at the bottom
                5. The next screen will ask you for a database name, enter Word_Automation_DB
                6. Wait for the spinner to finish and you should see your Viso Graphics Service app in the Service Applications list
                7. The Service App will indicate it's started, but the Service actually isn't running until you go to "System Settings" > Manage Services On Server and click the start button on the Secure Store Service line.
            14. Configure PowerPoint Conversion - I couldn't find any info in either book on this service so here's guidance based on info from technet: 
              1. Open a SharePoint Powershell window console as adminsitrator and run the following commands (press enter after each line)
                1. $pool = Get-SPServiceApplicationPool | where {$_.Name -eq "Default SharePoint Service App Pool"}
                2. $ppt = New-SPPowerPointConversionServiceApplication "PowerPoint Conversion Service" -ApplicationPool $pool
                3. New-SPPowerPointConversionServiceApplicationProxy "PowerPoint Conversion Service Proxy" -ServiceApplication $ppt -AddToDefaultGroup
                4. Start-SPServiceInstance | where($_.TypeName -eq "PowerPoint Conversion Service"}  [note:  when I ran this command I got prompted for the Identity parameter for the PowerPoint Conversion Service Instance (which was annoying).  You can get the Id by running Get-SPServiceInstance | where {$_.TypeName -eq "PowerPoint Conversion Service"}
            15. Configure Work Management (as stated earlie we have to provision 3 service apps to get this working)
              1. Configure Search Service.  You'll probably want to paste this into the ISE because there's quite a few lines:

                Add-PSSnapin "Microsoft.SharePoint.Powershell" -ErrorAction SilentlyContinue

                #ensure this matches the name of your SP Service App Pool

                $saAppPoolName = "Default SharePoint Service App Pool"

                #you should replace the value for the Server Name below with your server name

                $searchServerName ="SP2013DEVR201"
                $serviceAppName = "Search Service Application"
                $searchDBName = "Search_Service_DB"$saAppPool = Get-SPServiceApplicationPool $saAppPoolName
                #start Search Host Controller Service and Search Query and Site Settings Service (you should see these in the Manage Services on Server Page

                Start-SPEnterpriseSearchServiceInstance $searchServerName

                Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $searchServerName

                #create search application and proxy (you should see these on the Manage Service Applications Page, NOTE: the first line takes quite a while to run)

                $searchServiceApp = New-SPEnterpriseSearchServiceApplication -Name $serviceAppName -ApplicationPool $saAppPoolName -DatabaseName $searchDBName

                $searchProxy = New-SPEnterpriseSearchServiceApplicationProxy -Name "$serviceAppName Proxy" -SearchApplication $searchServiceApp

                #now clone the topology, add components

                $clone = $searchServiceApp.ActiveTopology.Clone()

                $searchServiceInstance = Get-SPEnterpriseSearchServiceInstance

                New-SPEnterpriseSearchAdminComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance

                New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance

                New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance

                New-SPEnterpriseSearchCrawlComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance

                New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance

                New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $clone -SearchServiceInstance $searchServiceInstance

                #finally, activate the topology, NOTE this also takes quite a while to run

                $clone.Activate()
              2. Configure User Profile Service (from CP guidance and in Chapter 14 of Professional SharePoint 2013 Administration)
                1. Configure the MySite web application
                  1. Following the CP guidance, you can run their "Script04_CreateWebApplications.ps1", but you have to edit the script and replace any reference to WINGTIP\Administrator to match the Admin account you're logged in as (you can't choose Administrator as your login in Azure since that's reserved) here.  Anyway, it's a good idea to read through the script.  This will create the MySite web application (along with the web app for the HNSC, Intranet, and Team sites)
                2. Next Configure the User Profile Service using the Script06_CreateUserProfileServiceApplication.ps1
                  1. Read through the  Script06_CreateUserProfileServiceApplication.ps1 and update the Administrator account (since you're not logged into your Azure VM as an account named "Administrator".
                  2. Read through the CreateUserProfileServiceApplicationScript.ps1 and ensure the server name/domain/accounts accurately reflect your environment.
                  3. Run the Script06_CreateUserProfileServiceApplication.ps1 and verify that it completes without error
                  4. Next go to CA > Manage Service Applications > User Profile Service Application
                  5. Create a new Synchronization Connection with the following values;
                    1. Connection Name: [Domain] Users (wingtip if you use CP guidance)
                    2. Type: Active Directory
                    3. ForestName:  yourdomain.com (e.g. wingtip.com)
                    4. Specify A domain controller
                    5. Domain Controller Name:  Your VM machine name
                    6. Authentication Provider Type:  Windows Authentication
                    7. Account Name: [DOMAIN]\SP_UPS
                    8. Password:  Password1 (if you've used the CP Guidance)
                    9. Click Populate containers, if you've configured the above correctly it should load your domain node
                    10. Choose the Users group the CP script set up.
                    11. Click OK
                  6. GO back to the User Profile Service Application management page and start a full import.   15 more profiles should get imported
            16. Configure Workflow
              1. Read through the Script05_CreateWorkflowFarm.ps1 script and ensure you update the reference from WINGTIP\Administrator to the correct Admin account
              2. Read through the CreateWorkflowFarmScript.ps1 and ensure you update the Administrator account as above.
              3. Run the Script05_CreateWorkflowFarm.ps1 script.
              4. NOTE:  If you decide to run the Script05 in the ISE, you'll get a security prompt when PS attempts to open another console window to run the CreateWorkflowFarmScript.ps1 so make sure you allow it when prompted.
            17. Finally,  Remove the SP_Farm account from the local admin group.
            18. Configure Search:
              1. We've already created the search application when we created the work management application but there's a few changes to make
                1. Go to CA>Manage Service Applications > Search Service
                2. Under content access account, change it to "SP_Crawler" rather than SP_Services or SP_Farm
                3. Now give SP_Crawler access to the user profile service application
                  1. go to CA > Manage Services on Server
                  2. Select the user profile service application (but don't click the link on the name) so that you can select Administrators from the ribbon
                  3. in the administrators dialog that pops up add SP_Crawler, then give it "Retrieve People Data for Search Crawlers" rights.
                4. You'll also need to go back to the Search Administration screen and add sps3://my.wingtip.com (or whatever you called it) as a content source and add a crawl rule to add the sps3://my.wingtip.com.
              2. Now start a full crawl  on the Local SharePoint sites content source (in the Search Service Application management screen)
              3. You should now be able to do the CP Search Tests described in their documentation (People Search for John, "Everything" search for Local_Admin - or whatever your admin User name is)

At this point you should be good to continue on P73 of the CP guidance and work your way through the rest of the config.  If you follow their directions (ensure you modify any domain/users and server names if you've strayed).

In summary, the CP Guidance is very good for beginners, but I encourage you to gain a full understanding of what their scripts do, and avoid the configuration wizard entirely as it's better that you understand all aspects of the setup rather than rely on Wizard Magic.

In the near future I'll try to get this guidance into an AutoSPInstaller script to really make things interesting.
        Summary of resources for this post:
        1. Critical Path Training VM Guide (this guide uses version 3.0):  available in the (free sign up) members section of www.criticalpath.com 
        2. Professional SharePoint 2013 Administration Book
        3. Shane Young's SQL Server Install guide for SP2013  
          1. Understanding Max Degrees of Parallelism

Thursday, July 10, 2014

SharePoint Solution Downloader

Special thanks to Djamel Chagour and his response to my MSDN thread (which linked to this blog post) to solve my issue of grabbing solutions from the Solution store so I could drop them on another server.

His post is more complex and deals with generating the stsadm commands for a batch deployment. Mine is the dumbed down version that just pulls the files so I can readd them as I need them.

Here's the code:



using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

using Microsoft.SharePoint;

using Microsoft.SharePoint.Administration;

using System.Xml;

using System.Web;



namespace Mirant.SharePoint.Administration.WSPDownloader

{

    class Program

    {

        static void Main(string[] args)

        {

            bool hasErrors = false;



            if (args.Length != 1)

            {

                Console.WriteLine("Usage: Company.SharePoint.Administration.WSPDownloader directory\r\n\tdirectory: full path on the local file system that you want the solutions downloaded to");

                hasErrors = true;

            }



            

            if (!hasErrors)

            {

                string path = args[0];

                path = path.Replace("\"", "");

                if (!path.EndsWith("\\"))

                    path += "\\";



      

                SPSolutionCollection solutions = SPFarm.Local.Solutions;



                foreach (SPSolution solution in solutions)

                {

                    SPPersistedFile wspFile = solution.SolutionFile;

                    wspFile.SaveAs(path + solution.Name);

                }

            }

             

        }

    }

}

Movin on Up: Converting a VDI to a VHD to move from VirtualBox to Azure

Months (years?) behind the rest of the world, I've finally decided it's time to get my VMs up to Azure (no more SSD swapping between PC and laptop despite having a easily mountable caddy in my work laptop and this sweet caddy in my PC.

As a loyal VirtualBox user I opted for VDI rather than VHD, but now I must convert.  So here's what I did:

  1. Uninstall VBox Guest Additions from the VM
  2. Shut the VM down (don't save the state).
  3. Remove the VDI from the Virtual Media Manager in Virtual box before running the command below
  4. Run the following command using Run As Administrator by right-clicking on the command prompt (from the VBox Install directory unless you've set the PATH variable):  VBoxManage clonehd e:\SP2013DEV.vdi  c:\SP2013DEVaz.vhd --format VHD

    In the above command the first file is the source VDI the second is the destination VHD.
  5. Wait for the magic to happen it should take a while since VMs with SP on them are pretty big.  Going from one drive to another should help a bit.
  6. Upload to Azure and config a new VM to use that VHD.
  7. Profit
I ran into a hiccup in that it appears my vbox installation got messed up during an upgrade and kept telling me that VBoxManage was not a vaild win32 application because it was a zero byte file.   Reinstalling VBox did the trick.

I may go to just configuring straight in Azure from now on. I do like the option of building locally then uploading, but I will probably just start with the VHD format from now on since conversion is really just an extra step if you plan on going to Azure.