3 April 2012

Managed Metadata - moving from test to production

Suppose you have a development machine which contains the model you want to deploy into production.  Suppose that Microsoft have provided a way to import Terms into the Term Store but no export mechanism.  You have two, well, three choices:
  1. Write a console app that writes out CSV files in the format MS have defined, use the import mechanism to move it across.
  2. The same but with Powershell.  This is slightly easier and there are a lot of examples.
  3. Use the method below I'm about to tell you about, still with PowerShell, to move the whole term store.
It's important to realise that while choice 1 and 2 will work, they will leave you with different GUIDs on the terms which means that you will have to relink them.  This could be a real pain if you are moving across document libraries and other content which already links to the terms.  Ideally we want to dump the whole term store from dev and bring it back on the production farm.  Fortunately, we can do that using a few lines of PowerShell through the SharePoint 2010 Management Shell:

On your development box, start the Management Shell and paste in the following (adjust this if you renamed your Managed Metadata service):

$mmsApplication = Get-SPServiceApplication | ? {$_.TypeName -eq "Managed Metadata Service"}
$mmsProxy = Get-SPServiceApplicationProxy | ? {$_.TypeName -eq "Managed Metadata Service Connection"}
Export-SPMetadataWebServicePartitionData $mmsApplication.Id -ServiceProxy $mmsProxy -Path "\\server1\share\mmsdata.cab"


On your production farm, start the Management shell and paste in the following (again, adjust to taste):

$mmsApplication = Get–SPServiceApplication | ? {$_.TypeName –eq "Managed Metadata Service"}
$mmsProxy = Get–SPServiceApplicationProxy | ? {$_.TypeName –eq "Managed Metadata Service Connection"}
Import–SPMetadataWebServicePartitionData $mmsApplication.Id –ServiceProxy $mmsProxy –Path "\\server1\share\mmsdata.cab" –OverwriteExisting

You should now have moved your term store from your dev farm to your production farm.  Note that the -OverwriteExisting argument does just that so take care!

2 April 2012

List Definitions the Easy Way

I discovered today that you can create a list definiton by saving your list as a template.  Although it still has a .stp extension (as it did in SP2007) instead of saving a file full of binary it creates a zipped archive which can be opened.  The file contains the xml required to paste into a blank list definition.  Much easier than cooking up your own from scratch!

Read this for more info:-
http://onlinecoder.blogspot.co.uk/2011/03/simple-way-of-creating-sharepoint-2010.html

30 March 2012

The sandboxed code execution request was refused because the Sandboxed Code Host Service was too busy to handle the request

Hello All.  I found an interesting bug and solution you might want to put in "long-term storage".  I have a SharePoint server which is the dev environment.  As per standard rules of least privelage, the farm runs using various service accounts, the majority of which have either no internet access or limited access - as internet access restrictions apply to user accounts where I work.  Everything passes through a proxy/content filter. 

I have just begun to explore Sandboxed solutions but immediately hit upon problem.  I was getting "The sandboxed code execution request was refused because the Sandboxed Code Host Service was too busy to handle the request".  Which is weird because everything is set up correctly and the server has loads of RAM and processors doing not much.  It was talking botox. 

I found that the "SharePoint 2010 User Code Host" service contacts Microsoft HQ to check certificate revokation.  If it gets no http response, it carries on and lets the thing run.  If it gets an http response but not the correct one, it gives this message.  Clever eh? 

So if you have a proxy/content filter which comes back with "Access denied due to corporate policy" (or some such) then it thinks it has made contact with Microsoft HQ but did not receive the response it wanted.  It then gets stuck in a timeout or retry loop. 

The fix for this is either to get the IT folks permit access to crl.microsoft.com (for the account running the User Code host service) or just add 127.0.0.1 crl.microsoft.com to your hosts file in C:\Windows\system32\drivers\etc (easier in my case) so that it gives up straight away without getting an http reply.