SharePoint dev strategies – it’s not all about Features!

Something I’ve been meaning to discuss for a long time is the decision to develop SharePoint artifacts using Features or some other approach. I actually discussed this back in May 2007 in my post SharePoint deployment options : Features or Content Deployment?, but feel it’s a topic worth revisiting/expanding on as I often see teams developing with Features without fully working out what exactly they are getting out of this approach. As you can guess by the article title, I’m not sold on the idea of using Features all the time (readers who have followed this blog from the start might find this surprising given I wrote many articles on how to work with Features) and want to put forward some points to consider when working out whether you need them or not.

Let’s first consider some (selected) characteristics of Features:

  • Provide a means of deploying SharePoint artifacts such as list templates/site columns/content types to multiple environments (e.g dev, test, production)
  • Currently the only way to deploy such artifacts across multiple site collections
  • Require some extra overhead to create, even with the community tools available (in comparison with creating artifacts directly in the SharePoint UI)
  • Little/no support for certain key updates (e.g. updating a content type which has already been deployed and is in use) – updates must be done through the user interface or the API, since modifying the original Feature files to make changes is unsupported.

Given these points, one scenario I really can’t see the benefit of Features for is when the solution consists of just one site collection – which is often the case for WCM sites. Why go through the extra hassle of packaging up artifacts into Features and be faced with difficulties managing updates when the artifacts will only ever exist in one site collection anyway? Sure, they may need to be deployed between environments but we have other ways of doing that.

N.B. The same applies to site definitions – why go to the trouble of creating a custom site definition when only one site will ever be created from it?

The alternative

If you aren’t forced into using Features to deal with multiple site collections, not using them could be the ‘most valid’ choice. In my recent WCM projects, I haven’t used Features for anything which doesn’t require a Feature (e.g. a VS workflow, a CustomAction etc.) for a long time now, including the project I discussed recently in SharePoint WCM in the finance sector and Developer lessons learnt – SharePoint WCM in the finance sector. Certainly given the extremely tight timescale on that project, I actually feel we could have failed to deliver on time if we had used Features.

Instead, my approach is to create a blank site in the dev environment, and do all the list/site column/content type/master page development there using the SharePoint UI and SPD. My next step (perhaps not surprising to regular readers) is to use my Content Deployment Wizard tool to move all the SharePoint artifacts to the other environments when ready. Equally, you could choose to write your own code which does the same thing using the now well-documented Content Deployment API. You’ll need to deal with any filesystem and .Net assets separately (generally before you import the SharePoint content on the destination), but in my view we’ve at least drastically simplified the SharePoint side of things. This seems to work well for many reasons:

  • More efficient since no development time lost to building Features
  • The update problem described earlier is taken care of for you (by the underlying Content Deployment API) – as an example, add a field to a content type in dev, deploy the content which uses it and the field will be added on the import site
  • Concept of a ‘package’ is maintained, so .cmp files produced by the Wizard can be handed to a hosting company for them to import using the Wizard at their end. I hear of quite a few people doing this.
  • We can store the .cmp files in source control and use them as part of a ‘Software Development Lifecycle’ approach. My approach (and I’d guess that of others using the tool in this way) is to store the .cmp file alongside the filesytem files such as .ascx files for the current ‘release’, and import them as part of the deployment process of moving the release to the next environment.

As an aside, when I decided to write a tool which would simplify dealing with dev/QA/UAT/production environments on SharePoint projects, I was initially torn between ‘solving the content type update problem’ and something based around the Content Deployment API. One reason why I decided on the latter was because the CD API already seemed to have solved the other issue!

Now I’m certainly not saying it works perfectly every time (it doesn’t, though is much improved following SP1 and infrastructure update), but in my experience I seem to spend less time over the course of a project resolving deployment issues than I would do building/troubleshooting Features. Additionally, using Content Deployment allows deployment of, well, content – if your solution relies on pre-created publishing pages or you have a scenario such as your client creating some content in UAT which needs to be moved to production before go-live, Features won’t help you here. The Content Deployment mechanism however, is designed for just that.

Where do Solutions (.wsp) fit in all this?

So to summarize the above, my rule of thumb for projects which aren’t built around multiple site collections is don’t use Features for things which don’t absolutely require them. So where does that leave Solution packages (.wsp files) – should they be abandoned too? Well no, definitely not in my view. Solutions solve a slightly different problem set:-

  • Deploying files to SharePoint web servers such that each server in a farm is a mirror of another. Ensuring all web front-ends have the same files used by SharePoint is, of course, a key requirement for SharePoint farms – this applies to Feature files when using them, but also to assemblies, 12 hive files etc.
  • Web.config modifications e.g. the ‘SafeControls’ entry required for custom web parts/controls
  • Code Access Security config modifications e.g. those required for controls not running from the GAC
  • Some other tasks, such as deployment of web part definition files (.webpart)

Really, there’s nothing stopping you from doing all this manually if you wanted to (especially if you’re always deploying to a single server, so there are less things to keep in sync). But the point here is that Solutions genuinely do make your life easier for comparatively little effort, so the ‘cost/benefit’ ratio is perhaps different to Features for me – the key is using one of the automated build approaches such as WSP Builder. So, my recommendation would generally be to always use Solutions for assemblies, 12 hive files etc., particularly in multiple server farm environments.

Conclusion

My rules of thumb then, are:

  • Consider not using Features (and site definitions) if your site isn’t based around multiple site collections – using the Wizard or some other solution based on Content Deployment can be the alternative
  • Use Solutions if you have multiple servers/environments, unless you’re happy to have more work to do to keep them in sync
  • If you are using Features, plan an approach for dealing with updates such as content type updates

My message here possibly goes against some of the guidance you might see other folks recommend, but I’m just going on the experience I’ve had delivering projects using different approaches. As always, the key is to consider deployment approach before you actually come to do it!

P.S. Also remember, deploying using backup and restore is a bad idea 😉

Recipe for successful use of Content Deployment Wizard

So my tool, the SharePoint Content Deployment Wizard has been available for some time now and I’ve been monitoring the feedback and issues people have raised closely. The current version is labelled ‘beta 2’ but I’m happy with the stability of the current codebase, so will probably re-label it as ‘release 1.0’ soon (following some feedback on the psychological aspect of the beta label :-)).

Only a small number of people have raised issues, and any problems have almost exclusively been related to the underlying Microsoft code used by the tool rather than the Wizard itself. I should probably be happy about this, but in reality if some people get errors from the tool it doesn’t really matter why it happens. The good news is that it seems Microsoft are finally getting some issues with the Content Deployment API sorted at their end. This is a key point in my list of guidance I’d give to anybody running into any errors from the Wizard. Note that the first two apply to use of standard Content Deployment using Central Admin also:

Tip 1 – Service Pack 1 and hotfixes matter

Service Pack 1 fixed many issues with Content Deployment. Unfortunately it also broke some things which had previously been fixed with pre-SP1 hotfixes. It took me a while to realize this, but it’s definitely the case. Probably the most common issue in this area is the ‘Violation of Primary Key‘ error. There are reports of being able to work around this by modifying versioning settings on certain libraries, but MS have now released a hotfix very recently which seems to solve the problem for good on SP1 environments. At the moment this is by special request only – the KB to ask for is KB950279. This forum thread discusses this, and it worked for us. Interestingly I spoke to Tyler Butler (Program Manager for Content Deployment) at SPC2008, and he indicated Content Deployment in SharePoint is likely to get “significantly more stable in the next 30-60 days”. I’m guessing this hotfix is what he was referring to, or at least part of it.

Tip 2 – always start from a blank site template an empty site created from STSADM -o createsite on the destination

The official guidance currently states that Content Deployment requires that the target site has been created from the ‘blank’ site template – this is detailed in KB article 923592. However, a better way detailed by Stefan in the comments below is to create an empty site using the STSADM -o createsite command. This is not the same as a site created from the blank template, and is the safest way to create sites which will use Content Deployment or the Wizard. What this means is that even if you’re creating a site based on say, the publishing site template in development, any other environments which you wish to deploy content to should be created in this way. Notably, for publishing sites the publishing Feature should also not be enabled for the first deployment – this will be taken care of for you when the first deployment happens. You’ll receive the same ‘object already exists’ error otherwise.

Tip 3 – pay attention to the ‘retain object IDs’ option

Generally the right option here is to select that you do want to retain the object IDs, and this should be done from the very first deployment – the only exception is when moving webs/lists to a different part of the site structure (reparenting). However, it’s important to note that mixing use of Content Deployment or the Wizard with STSADM export/import is likely to cause problems as noted by Stefan in his recommended ‘Content Deployment and Migration API – avoiding common problems‘ post.

A more comprehensive write-up of options available with the Wizard is available at ‘Using the SharePoint Content Deployment Wizard‘. Also note that’s not it as far as the tool goes – in addition to extra functionality such as item-level reparenting and incremental deployment, I hope to refactor the code so that the Wizard would be scriptable from the command-line.

And special thanks go to my colleague Nigel Price for working through the hotfix situation, much appreciated 🙂

New version of Content Deployment Wizard released

I’m happy to announce that development/testing of the next version of the SharePoint Content Deployment Wizard is now complete, and the new release has been uploaded to Codeplex. If you’re not aware of the tool then Introducing the SharePoint Content Deployment Wizard is a good place to start. I’m calling this release "beta 2", which indicates the tool is by no means complete, but is significantly more mature than the original version. I’d encourage all of the 1400+ people (and counting) who downloaded the original in the past few weeks to get the latest version – the link is at the bottom of this post.

So let’s run through the improvements:

  • Better support for large sites:

    The treeview of the site is no longer built in one hit – instead, portions of the site are retrieved as webs/lists are expanded. This can make a huge difference when working with large sites.
  • Support for WSS-only sites:

    The dependency on the MOSS assembly (Microsoft.SharePoint.Publishing) has now been removed, so imports/exports to WSS sites are now possible. The MOSS-specific functionality is only used if we are indeed in a MOSS environment – if you’re interested, this is just related to honoring any publishing schedules (i.e. page expiry) from the source site on the target site.

  • Everything in one .exe:

    No separate WizardBase.dll any more.

  • Easier access to log files after import/export:

    Since it’s highly important to analyze the log file for errors/warnings after an import/export, these now open automatically in notepad at the end of the operation. There’s also a link in the tool to open the log file, so no more manual digging around the filesystem.
  • Auto-discovery of sites in ‘Site URL’ box:

    No need to re-enter the site URL each time – the sites available for selection in your SharePoint environment are automatically shown in the auto-complete entries for the textbox:

     AutoSiteDiscovery

  • Pretty icons in treeview 🙂

    Easier visual distinction between objects in the tree:
     TreeViewImages
  • Logging via System.Diagnostics.Trace:

    In addition to the log file generated by the actual import/export operation, general operations in the tool are now also logged (separately) via System.Diagnostics. So if you have a problem using the tool, it should be easier to pinpoint the actual error – enable by adding a .config file with a TraceSwitch entry for "COB.SharePoint.Utilities.ContentDeploymentWizard" and appropriate TraceListener entries.

  • More reliability:

    Miscellaneous minor bug fixes, including removal of the somewhat psychedelic flickering as the confirmation screen is built.

In terms of issues reported in the first release, it seems that 95% of them have been related to the underlying Content Migration API provided by SharePoint rather than the actual Wizard – this means the issue would also likely surface if out-of-the-box Content Deployment (via Central Admin) or STSADM -export was used to deploy the content instead. This is in line with what I was expecting since in many ways the Wizard doesn’t actually do that much – it just presents a nice UI (with the ability to cherry-pick exactly which items should be deployed) onto existing SharePoint code. Since there are some gotchas with the MS bits however, it does mean that understanding how their API works can help when using the Wizard. My recommended reading list for those wanting to know more would be:

The future

I’ve had great feedback so far (ranging from feature requests to "why the hell don’t you charge for this thing?!" to offers of collaboration). In terms of features, it looks like incremental deployment is the most popular vote so far so I’m hoping to add this fairly soon. Another possibility is making the Wizard scriptable by refactoring the code into something more tiered, thus providing features like the ability to save configurations for import/export jobs and also allowing them to be hooked up to a task scheduler in some way. 

However, the more feedback the better and if you’d like to see particular functionality or have run into problems trying to use the tool I’m definitely keen to hear. Either leave a comment on the blog or over at the Codeplex site.

The download link
 

Go to www.codeplex.com/SPDeploymentWizard and go to the releases tab to download the latest version. Hope you find it useful.

Using the SharePoint Content Deployment Wizard

So if you’ve read the earlier posts about the tool (Introducing the SharePoint Content Deployment Wizard and When to use the SharePoint Content Deployment Wizard) and figure this is a useful tool, let’s go onto the next level of detail. Generally speaking the Content Deployment Wizard ‘just works’, but if you want to know more about the different options, read on. This post contains reference information and a guide to some deployment scenarios at the end.

Firstly, let’s remind ourselves of some of the fundamental things to remember when moving content using the Content Migration API (the underlying SharePoint API used by the tool):

  • dependencies of selected content (e.g. referenced CSS files, master pages) can be evaluated – in the tool they are automatically included in the export – check ‘Exclude dependencies of selected objects’ to disable this
  • all required content types, columns etc. are automatically included in the export
  • in contrast to STSADM export, it is possible to retain GUIDs during deployment (where objects are not being reparented) – check ‘Retain object IDs and locations’ to enable this
  • no filesystem files (assemblies, SharePoint Solutions/Features etc.) are deployed – these must already be present on the target for the import to succeed)
  • the following content does not get captured by the Content Migration API – alerts, audit trail, change log history, recycle-bin items, workflow tasks/state

In particular it’s the 2nd and 3rd points which make the API (and the Wizard) a good way to deploy content in SharePoint.

What can be deployed?

The Content Deployment Wizard allows any content to be selected for export – site collections, webs, lists/document libraries, folders, right down to individual list items and files. Objects in the treeview can be added to the export by right-clicking them, which for a web, brings up a menu shown below:

These are explained:-

  • ‘include all descendents’ – exports the container and anything beneath it
  • ‘exclude descendents’ – exports the container only
  • on webs only, the ‘include content descendents’ option is shown – this will include all immediate content such as lists/libraries, but will exclude all child webs of the web.

Note that on the import, the Wizard will bring in all the contents of the selected .cmp file(s) – there is no option to partially import a package. Hence if different import options are required for different content, the exports should be broken into separate chunks.

Export options

On the export settings screen, numerous options can be applied to exports:

  • ‘Exclude dependencies of selected objects’ – by default the Content Migration API will automatically include dependent objects of whatever you select. This can include CSS files, master pages, images and the like, but also list items which are displayed on a page included in the export. This can be turned off with this checkbox so only the objects you select are exported.
  • ‘Export method’ (options are ‘ExportAll’, ‘ExportChanges’) – for now ExportAll is the option to select, ability to export changes only will come in a future release
  • ‘Include versions’ (options are ‘LastMajor’, ‘CurrentVersion’, ‘LastMajorAndMinor’, ‘All’) – should be self-explanatory
  • ‘Include security’ (options are ‘None’, ‘WssOnly’, ‘All’)’ – note that since security is defined at the level of a web, selecting one of the include security options for a smaller object (e.g. list) actually exports security for the entire web. Both ‘WssOnly’ and ‘All’ export SharePoint item-level object permissions, so if you’re using SharePoint groups to manage security for example, both the actual permissions and groups will be carried over, and you can add a different set of users/AD groups on the destination. See Migrating Security Information on MSDN for more details.

Import options

On the import we also have several options, some of which correspond to options selected on the export:

  • ‘Import web URL’ (actually shown on the ‘Bind to site’ screen) – this is used for reparenting operations only. If you are just moving content from source to destination but are not changing the location in the structure, this textbox can remain blank. Alternatively, for operations where a web or list is being imported but the parent web will not be the exact same web on the destination, the URL of the new target web URL should be entered.

    Note that the later option to ‘Retain object IDs and locations’ should not be selected when reparenting, since we are changing the location in this case.

  • ‘From single file’/’From multiple files’ options – the Wizard always exports with file compression enabled, so when exporting content over 25MB, files are split into several files at this threshold. When importing from such an export, select the ‘From multiple files’ option and browse to the folder. In the textbox, enter the ‘base filename’ – this should be the name of the first file without the number e.g. ‘MyExport.cmp’ rather than ‘MyExport1.cmp’. 
  • Retain object IDs and locations’ – this setting requires particular consideration. Duplicate GUIDs are not permitted in one database (i.e. SP web application), so the choice often depends on what you are importing. If you are taking a site from development to production, the object GUIDs will not yet exist on the destination, so I check the box to ensure the objects are assigned the same IDs in both environments, and all linkages are preserved. If you are reparenting a list or web, you will leave the box unchecked, so that new GUIDs are assigned are the location can therefore be changed.

    I highly recommend reading the content listed in the ‘Useful links’ section at the end of the article to properly understand this setting.

  • ‘Include security’ – this allows security information in a package to be imported, assuming one of the options to include security was selected on the export
  • ‘Version updates’ – allows control over whether new versions should be added to existing files, or whether the existing version should be replaced etc.
  • ‘User info update’ – allows control over whether ‘last modified’ information should be imported. Often this only makes sense if the same set of users exist in the source and destination

Scenarios quick reference

The following table lists the most common settings for a given deployment task:

Deployment item

Typical settings

Entire site collection
  • Site collection should first be created on the destination.
  • When exporting, select ‘include all descendents’.
  • When importing for the first time, ensure ‘retain object IDs and locations’ is checked.
  • Select one of the ‘include security’ options if you wish to deploy object permissions and users
Web
  • When exporting, select ‘include all descendents’.
  • When importing for the first time, ensure ‘retain object IDs and locations’ is checked if web will have same parent as on source.
  • If web will have a different parent, do not check retain object IDs and locations’ and ensure ‘import web URL’ is specified
Document library/list
  • When exporting, select ‘include all descendents’.
  • When importing for the first time, ensure ‘retain object IDs and locations’ is checked if list will have same parent as on source (i.e. not reparenting).
  • On subsequent imports, ensure ‘import web URL’ is specified if not importing to the root web, and do not check ‘retain object IDs and locations’
File/list item
  • Ensure the parent library/list exists on the destination
  • Do not check ‘retain object IDs and locations’ if the item already exists on the destination

 

So hopefully that’s some useful reference information. On a final note, the next beta version with much improved treeview performance should be ready over the next week or so!

Useful links

When to use the SharePoint Content Deployment Wizard

Following my introduction to the tool last time, today I want to try to help position the tool for people who aren’t sure if it could be useful to them or for what scenarios – if you only take one thing away from my postings on the Content Deployment Wizard it should be this.

I see the ‘value-add’ of the Content Deployment Wizard over existing deployment methods such as STSADM export/content deployment in Central Administration to be:

  • ability to “cherry-pick” content to deploy using a treeview – this is from entire site collection down to individual list item or file. (This is the big one since the standard SharePoint tools do not supply a method to do this)
  • ability to control whether object GUIDs are retained – this is required for scenarios where the destination should be a mirror-image of the source, such as staging/production environments for the same site
  • ability to move certain objects (limited to webs and lists in the initial release) to a new location on the import target, known as ‘reparenting’

I would suggest the tool could well have a place in your SharePoint toolbox, but it’s likely to be something you use every now and then, rather than all the time. The two main scenarios where I use the tool are:

  • at the end of the development phase when I need to move a site from development to staging/production. Here, the tool allows me to be sure that all relationships/linkages between objects will be preserved (so no problems with ListViewWebParts/DataViewWebParts/InfoPath forms for example)
  • any odd occasions where I have a need to move a particular document library/list, or a particular set of files (e.g. master page, page layouts, CSS etc.). This assumes by the way, that the files were not deployed with a feature – I wouldn’t recommend mixing the deployment methods like that.

N.B. It should also be possible to use the tool for ongoing updates to specific files/list items through different environments in a development/test/staging/production situation. An example of this is deployment of just master pages, page layouts and CSS files on a WCM site (meaning all other content authored by the client [e.g. in the ‘Pages’ library] does not get overwritten on the target) but I haven’t had the opportunity to try this on a real project yet.

Some areas where the tool cannot be used (i.e. the tool does not yet support this usage) are:

  • exporting only changes since a certain timestamp (change token) from a site
  • importing individual list items/files to a new location on the target (reparenting)

On the last point, the ‘new location’ would be a document library or list, since these items have to be in such a container – they cannot exist at the root of a web. Currently the tool supports reparenting webs and lists, but not individual list items/files. What is currently possible with individual list items/files, is moving selected items from a source to a target where the structure is the same (e.g. move Doc2 and Doc5 from “Team documents” on the source to “Team Documents” on the target). Usefully, whenever a file is exported/imported using the tool, the associated list item is also deployed, meaning metadata updates to column values are deployable.

Hopefully that might help you understand where the Wizard fits in. If you’re thinking the Wizard could be useful to you from time to time, stay tuned for my next post which will have more detailed ‘usage’ information. 

Introducing the SharePoint Content Deployment Wizard

Regular readers might have spotted I’ve been slightly quieter than usual over the past few weeks – actually I’ve not been slacking, but working on a tool which you might find useful from time to time. As I’ve discussed in numerous posts, deployment of SharePoint artifacts is something that’s perhaps more complex than it should be, and the standard tools provided don’t always simplify this picture. Personally, over my past few MOSS projects, there have been several times when I’ve thought:

  • I just need to move this document library from A to B
  • I just need to move these selected files (e.g. master page, page layouts, CSS etc.) from A to B
  • I just need to move this web from A to B
  • I just need to move this site collection from A to B
  • I just need to move these 20 list items from A to B

If only there was an easy way! CMS 2002 users may remember the SDO export mechanism which allowed you to use a treeview to select exactly which content you wished to move, but unfortunately there’s no similar tool for MOSS. Sure, we have Content Deployment and STSADM export etc., but the lowest level of granularity is a web, and if you don’t want to overwrite the whole thing neither option can be used. The only other option is to write code which uses the Content Migration API. This is fine for projects which have the appropriate development skills and time, but otherwise things can be tricky.

Enter the SharePoint Content Deployment Wizard.

The tool provides a wizard-like approach to deploying content between SharePoint sites. The selected content is exported using the Content Migration API (PRIME), giving a .cmp file (Content Migration Package) which can be copied to other servers.

Since pictures are often more useful than words, let’s look at using the tool. Click to enlarge any of the images below:

EXPORTING CONTENT

Welcome screen (click any image to enlarge):


Select action (import or export) and provide site URL:

 

For export, use the treeview to select which content you wish to deploy. On container objects such as webs, there are options about whether descendent objects should be included:

 
Select options around security, dependencies, versions and name of the export file:
 
 
 
The details are shown back for confirmation, and when ‘Finish’ is clicked the export will begin:
 
 
 
IMPORTING CONTENT
 

Browse to the .cmp file we exported in the previous steps, and select options around security, versions and, importantly for some scenarios, whether object IDs should be retained:
 
 

The details are shown back for confirmation, and when ‘Finish’ is clicked the import will begin:
 
 
 

And that’s the gist of it. This is the first beta of the tool and I’m sure there will be issues. Regardless, when using any tool which makes this kind of change to your data you should always take a backup before performing the import. Depending on what you’re doing, it could be difficult to revert back to the previous state otherwise.

Some other notes:

  • the tool must be installed locally on the server which hosts the site
  • not all features of the Content Migration API are supported by the tool
  • the next beta (mid-December) will properly support large sites – currently the site bind operation can be slow for large sites since the treeview is built in one operation
  • it must be run under an account which has the appropriate permissions to the SharePoint site – use the Windows ‘Run as..’ feature to do this if necessary (shown below in the image below- right-click on the .exe and select ‘Run as..’)

 
In the next post, I’ll cover details on different usages of the tool and the effect of different options. The tool also supports reparenting (e.g. importing a web or list to a different parent on the target) and I’ll talk about this.

You can download the tool now from www.codeplex.com/SPDeploymentWizard. All feedback (particularly bug reports) welcome, either post here or on the Codeplex site.

Change a SharePoint site’s URL

Something you may find yourself tasked with at some point, is changing the URL of an existing SharePoint 2007 site. This is a fairly interesting scenario, and it’s fair to say the relationship between SharePoint and IIS makes this more complex than for a standard .Net site. However, there are several possible solutions. The first things many of us would think of as potential approaches would probably be:

  • extending the web application onto another URL
  • using Alternate Access Mappings somehow

Depending on your site both could be valid methods, but as with anything SharePoint-related, there are different things to watch out for with the different approaches. As an example, extending the web application wasn’t the right approach for our scenario for the following reasons:

  • the site shouldn’t actually exist at the old URL, but a redirect was required
  • InfoPath forms don’t seem to deal well with the ‘extended web application’ configuration. (Problem detail – on one URL everything will be fine, but if the two web applications use separate site collections, on the other you’re likely to see security errors when opening forms. This is because the form templates are referenced in the other site collection – a document library can only have one URL to the document template, and publishing a form to a content type stores an absolute link in the content database.)

Additionally some quick tests with Alternate Access Mappings didn’t seem to give the expected results for me, so I decided on another approach since I knew it would work and didn’t have much time for experimentation. So this was my process:

Changing a site’s URL by recreating the site (downtime required)

  1. Stop old IIS site.
  2. Create new web application in SharePoint, bind to new IP address in IIS.
  3. Apply SSL certificate if appropriate.
  4. Create new site collection for this web application using the blank site template.
  5. Export content using the SharePoint’s content migration API (I have a tool which does this, which will shortly be on Codeplex) ensuring all security data is exported. Alternatives to this step include STSADM -O BACKUP and STSADM-O EXPORT. *
  6. Import content into the new site collection, ensuring to include security.
  7. Amend any absolute URLs in .udcx data connection files used by InfoPath.
  8. Republish any InfoPath forms to the new site.
  9. Configure search:
    1. Ensure new URL is a content source.
    2. Update any crawl rules which use absolute URLs.
    3. Update ‘authoritative pages’ as appropriate.
    4. Start full crawl.
    5. Update scopes.
    6. Go to Site Settings > Site collection administration > Search scopes, add any custom scopes to search dropdown (if using standard search web parts).
    7. Ensure search web parts use relative URLs/do not reference old site URLs.
  10. If a redirect from old URL is required, create new IIS site to implement this:
    1. Create new site in IIS and bind to old IP address.
    2. On ‘Home directory’ tab, specify content should come from ‘A redirection to a URL’ and enter the URL.
  11. Ensure DNS/firewalls are configured appropriately for new URL, remembering to allow appropriate time for DNS propagation.
  12. Perform testing.

* N.B. Between the content migration API and STSADM export, I prefer the former since this allows control over whether object GUIDs are retained (more information in STSADM export, Content Deployment, Content Migration API, Features/Solutions – deployment options compared). STSADM backup/restore is discussed in next section.

Considerations to this approach

  • When using the content migration API or STSADM backup/restore, the following items are not included – alerts, workflows, recycle bin state or site collection properties. These must be migrated/recreated separately.
  • Regression testing is absolutely required since the site is effectively recreated

As a way to improve on the first consideration, another option would be STSADM backup/restore (though I’ve not tried this approach). Notably this method does collect data for the items which the other approaches exclude, however due to the nature of our site, none of these were significant problems.

So this method was successful, and hopefully this information allows folks to see some of the pros and cons without having to spend the time going through it themselves. However, I also note an approach based on Alternate Access Mappings suggested by Faraz Khan. Since this was only published in the few days before this article it was too late for my scenario, though I’d encourage you to take a look. Note that Faraz also points out considerations such as certain links not being updated to new URL without fix-ups, though this doesn’t seem to be a major issue. It does echo my point about there being different things to watch out for with the different approaches, but both methods provide valid techniques for changing a SharePoint site’s URL.