The blog of Wictor Wilén

  • Office Web Apps Server will only be available for Volume License customers shortly

    Tags: Office Web Apps

    Office Web AppsToday the Office Updates blog added a new blog post titled “Web Apps Server Removal from Download Center”. The contents of that blog post is short:

    As of 11-24-2014 Office Web Apps Server will be removed from the Microsoft Download Center.  At that time it will only be available for download under Volume Licensing agreements.  For more information please visit the site Volume Licensing Service Center.

    Office Web Apps Server, used by SharePoint, Exchange and Lync to view, preview and edit Office documents is and has been one of the key features/add-ons of these products and allows for browser based editing and collaboration. It has up until now been available as a free download, free from licensing for reading but requiring Office client licensing for editing.

    So from the 24th of November you will not be able to download Office Web Apps Server (WAC) from the Microsoft Download center. To download it you will be required to have a Volume License agreement with Microsoft and you will only be able to download it from the Volume Licensing Service Center.

    Why this move? I don’t know. I will try to find out though… This will most likely cause a annoyances for developers and when testing, but I assume that most organizations using WAC likely have a Volume License agreement anyways. What do you think?

    [Update 2014-10-29]: The original blog post has been updated with a small FAQ. The interesting things to note there is that for evaluation there will still be a downloadable copy for MSDN subscribers, and “EXISTING [my emphasis] Web Apps Server installations will continue to be licensed for viewing”. That leaves us with the question – will Office Web Apps Server NOT be free for viewing from now on?

  • SharePoint MVP AMA on October 29th

    Tags: SharePoint, Office 365

    You should mark the 29th of October at 1pm EST (18:00 CET) in your calendar. The MVP Chats are back!

    A couple of years back we regularly held MVP chats where anyone could ask SharePoint MVPs anything (almost at least). These chats was really successful and we received really good feedback. Unfortunately the tool we used for the chats was abandoned and we have been looking for a new way to do this. We think we’ve found a really interesting format for this by using the AMA format at Reddit (/r/sharepoint).

    [Update 2014-10-29]: The thread is located here: http://www.reddit.com/r/sharepoint/comments/2kojof/ama_time_we_are_a_bunch_of_microsoft_mvps_for/

    There will be at least fifteen SharePoint MVP’s answering YOUR questions so feel free to tune it the 29th. We will try to make sure that at least one MVP answers your question, the ones most skilled in the topic of the question, and we’ll make sure that not everyone answers it (which normally is an issue with forums like this).

    We will have experts from infrastructure, to design, to development, to no-code (all definitions of that!) solutions and more, for both SharePoint and Office 365 This will be a great opportunity for all of you to finally get that hard question answered.

    If this turns out to be a successful event I’m pretty sure we will do it again! And to get as much questions as possible, spread the word and use the hashtag #spmvpchat.

  • Speaking at Share-The-Point Southeast Asia 2014

    Tags: Conferences, SharePoint, Microsoft Azure

    See you there!I’m so excited to be once again going to Singapore and speak at the Share-The-Point Southeast Asia 2014, held November 25-26 2014. It is one of my favorite conferences and this will be my third time in the awesome country and city of Singapore! Everything is just great about this; the people, the speakers, the attendees, the city, the food – you name it!

    This year I will have two sessions:

    • Using Microsoft Azure for your SharePoint and Office Apps
      One of my personal favorite sessions, scenario based and packed with demos showing you tips and tricks, awesome Azure features and lots of code.
    • Building out your SharePoint Infrastructure using Azure
      Another really interesting session where I’ll walk you through the pros and cons, the do’s and don’ts of hosting your SharePoint infrastructure in Azure.

     

    If you are planning to be close to Singapore during those days you should make sure to get your conference passes as soon as possible! OR, if you have trouble convincing your boss about what you and your company will miss if you bail out of this, leave a comment (with your e-mail) and the first three persons will get a free pass (full attendance to the 2 day event, including catering and access to the exhibition area and all sessions) – what are you waiting for?

  • Presenting the new Office 365 APIs at TechDays in Sweden

    Tags: Presentations, Office 365

    TechDays 2014I’m thrilled to be presenting at TechDays 2014 in Stockholm the 19-20 November. This is the 5th time the TechDays conference is held here in Sweden and I know that this years edition will be even more awesome than the previous times. As usual the best speakers from Sweden will be there and some international really interesting speakers, such as the well-known Mary Jo Foley.

    I will be presenting a session about the new and interesting Office 365 APIs. We will walk through what these new APIs do, what they can be used for, how to do authentication and why you should invest your time in these APIs. It will be a developer focused session and we will look at code as much as possible – and we will have as much fun as possible.

    I really look forward to meeting you there, and if you’re not already booked, then head on over to your manager and say that if he or she doesn’t send you to TechDays, then you will in the wake of your competitors. Oh, and by the way, don’t miss out on the early bird offer which is valid until the last of august.

  • The SharePoint Team is listening - make your voice heard

    Tags: SharePoint 2013, Office 365, Microsoft

    There’s a lot of stuff happening right now at Microsoft, they innovate, create great software and services, the new CEO accepts and wins almost all challenges and the SharePoint and Office team is listening! This is the Microsoft that I like and this is how I want Microsoft to continue to be. But Microsoft and the SharePoint team can’t just listen in blind – they listens to us out here in the real world, customers, clients etc. and we need to make our voice heard. This can be done in several ways, we can talk to our Microsoft representatives, we can whine on our blogs and on social networks OR we could make ourselves heard at UserVoice.

    Microsoft and different divisions and groups within Microsoft has started to use UserVoice pretty extensively lately. UserVoice is a great service where you can set up your own channel, listen for feedback and questions, and answer them and most importantly act upon them. Just recently the SharePoint team had a blog post called “UserVoice driving improvements to SharePoint API” which shows just this. From the feedback they received on UserVoice and with direct and indirect customer contact they’ve made some pretty significant improvements to the SharePoint API’s, such as JSON Light support and others. I really dig this!

    FeedbackSo, if you have a suggestion or improvement to Office, SharePoint and/or the Office 365 service then get your sorry behind over to UserVoice and make yourself heard. Read other peoples suggestions and vote on them. The more votes, the more likely the teams will pick up it.

    Here are some of the UserVoice channels that Microsoft and the different product groups use:

     

    One suggestion that I made the other day was a suggestion that the Office/SharePoint/Office 365 team has a publically posted “change log”. I would like them to post any changes done to the API, UI, CSS, JavaScript, PowerShell etc in a chronological change log, so we don’t have to read between the lines in KB articles etc. If you think that this is a great idea, then I invite you to vote on my suggestion here: http://officespdev.uservoice.com/forums/224641-general/suggestions/6297224-sharepoint-and-sharepoint-online-change-log

  • SharePoint 2013: Using the App Only policy and App Principals instead of username and password combos

    Tags: SharePoint 2013, Apps

    Introduction

    One of the blog post I receive the most e-mails about is the How to do active authentication to Office 365 and SharePoint Online. Some of the feedback I get is “thank you” etc. and some of them are people that are modifying it for all kind of things, especially when trying to do “background jobs” or integrations using user credentials. And this is what this post is all about. My standard answer to that question is that you do not want to use the methods in that post for those scenarios, nowadays, since you can actually build an App for that. And even better you can build an App with a so called App Only policy – which means that we do not need to have any user credentials or anything like that. So in order to save me some time in replying that and then another reply on the “how do I do that?” question I can from now on only link to this post :-)

    Scenario

    Before we dig down to the actual nuts and bolts, let’s have a scenario in front of us. Assume we have a SharePoint site containing a product list (or similar). We would like an application/app/service/background job (you name it) to read and potentially write to this list. This is a very common scenario and traditionally this was built as timer jobs in SharePoint, or scheduled tasks running as specific users or even with hardcoded username and passwords (yikes!). In this sample we will instead use an App Principal, this is very much like a user principal which you can give permissions to in SharePoint.

    In this simple example I will use a site containing a list of products (two columns; Title and Price) and then an ASP.NET MVC web site that will show that list of products. An no, I will not build a SharePoint App, but instead show how you can take advantage of App Principals to get the products from SharePoint without using any user credentials whatsoever.

    Create the App Principal

    Register an App The first thing we would like to do once we have created our site and the list of products is to generate an App Principal with access to read from this list of products. This is done by navigating to your site and then appending /_layouts/15/AppRegNew.aspx to the URL so that you end up on the “Register an App” page. On that page click on the two Generate buttons to generate an App Id and an App Secret, then provide a Title for your App and the domain (localhost in this demo) for your app.

    Once that is done you will get a confirmation and a summary of the app identifier created. Screenshot this and/or copy and paste it so that you have the details, you will need them later.

    Give the app some permissonsNext we need to grant permissions to this app. This is done by navigating to /_layouts/15/AppInv.aspx. On that page paste your App Id (generated previously) into the App Id text box and click on the Lookup button, this will retrieve the details of the app and give us the opportunity to give the app some permissions.

    Giving the app permissions is not for the faint hearted and the UI is horrible (just like basically any admin UI in SharePoint). You need to write a valid app permission request XML. In this case I only want read rights to a specific list, nothing more, and I also want the app to be able to retrieve this data without any user credentials (App Only). The resulting XML looks like below, and the key thing is the AllowAppOnlyPolicy attribute:

    <AppPermissionRequests AllowAppOnlyPolicy="true">
      <AppPermissionRequest
        Scope="http://sharepoint/content/sitecollection/web/list"
        Right="Read"/>
    </AppPermissionRequests>

    When you click the Create button you will be taken to the “Do you trust” page, where you should trust your app. Since we requested to be able read from a list, we must also choose which list that we should read from. Once we’ve done that we click “Trust it”. One crappy thing is that if you would like to modify the permissions later, you need to re-write the XML completely since the UI does not retrieve the current requested permissions, so you need to document and save your XML.

    Trust the app!

    If you don’t want to study the app permission request schema I recommend you to look at this MSDN page which will give you some more insights.

    (Optional) High-trust apps for on-premises usage

    If you’re now doing this for on-premises deployments and do not have configured your farm for low-trust apps (integration with ACS), then you also need to register a high-trust app. To not repeat myself, you can use the same set of PowerShell that I used in the SharePoint 2013 with SAML Claims and Provider Hosted Apps blog post. Just make sure that you generate a new Issuer Id (which is not the same as the Client Id you got above when registering the app.

    Building the ASP.NET MVC site

    Now it is time to start building the consumer of this products list, in this case an ASP.NET MVC site (but it could be basically anything). Fire up Visual Studio 2013, create a new ASP.NET Web Application, then choose MVC and configure it as you like.

    App for SharePoint Web Toolkit NuGet packageThe first thing we need to do is to download a very sweet NuGet package. It is called “App for SharePoint Web Toolkit”. This “little” package will install the SharePoint 2013 client assemblies and also add the TokenHelper.cs and SharePointContext.cs files that you should be familiar with from a normal Provider Hosted SharePoint App.

    Update the web.config

    Before we start writing the code to retrieve the products from the SharePoint list we need to add some plumbing into the web.config. Depending on if you’re using ACS or using the High-Trust approach you need to add different configuration. For a low-trust approach you only need the first two lines (ClientId and ClientSecret that you got from AppRegNew.aspx) and for the high-trust approach you need all settings below, except the ClientSecret, and you also need to have the pfx file of the certificate used for the high-trust configuration.

    <add key="ClientId" value="d0ee6f6d-1c39-44b2-a284-f3143e820ec2"/>
    <add key="ClientSecret" value="11Flt0LME9mnToNhRN5nmgeynAXW3nMBvJBrIBGlT/o="/>
    
    <add key="ClientSigningCertificatePath" value="C:\temp\AppOnlySite.pfx" />
    <add key="ClientSigningCertificatePassword" value="Pass@word1" />
    <add key="IssuerId" value="93d08816-eb35-4ed9-be90-ea352cc81130" />
    

    Modifying the Home Controller

    To read the stuff from our SharePoint list I modify the Index action of the Home Controller so that it looks like this:

    public async Task<ActionResult> Index()
    {            
        Uri site = new Uri("https://intranet.sp01.contoso.com/sites/productlist");
        string realm = TokenHelper.GetRealmFromTargetUrl(site);
    
        // For use with ACS/SPO
        //var tokenResponse = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, site.Authority, realm);
        //var accessToken = tokenResponse.AccessToken;
                
        // High Trust
        var accessToken = TokenHelper.GetS2SAccessTokenWithWindowsIdentity(site, null);
                
        UriBuilder builder = new UriBuilder(site);
        builder.Path += "/_api/lists/GetByTitle('Products')/Items";
        builder.Query = "$select=Title,Price";
    
        HttpClient client = new HttpClient();
        client.DefaultRequestHeaders.Add("Accept", "application/json;odata=verbose");
        client.DefaultRequestHeaders.Add("Authorization", "Bearer " + accessToken);
    
        var response = await client.GetAsync(builder.Uri);
    
        var result = JsonConvert.DeserializeObject<ProductResponse>(await response.Content.ReadAsStringAsync());
    
        return View(result.Data.Results);
    }

    The first thing I do is to modify the method signature (#1) and declare it with the async keyword, so that I later can use the await keyword for the asynchronous operations. Then I use the TokenHelper class to retrieve the realm (#4)and the access token (#8 || #11). As you can see there are two different ways to retrieve the access token for an App Only principal, one when using ACS and one when using the High-Trust approach.

    Once I have the access token I build the REST URL (#13-15) and then create the HttpClient that I will use to invoke the REST end-point. On line #18 I specify that I want the data back in JSON format and on line #19 I pass the access token for authorization.

    Once that is all done we only need to invoke our HTTP client and retrieve the result. Once we have the result I use the JsonConverter to deserialize the data into a nice object structure (ProductResponse). In order to more easily work with the data returned I created these POCOs:

    public class ProductResponse
    {
        [JsonProperty("d")]
        public ProductResult Data { get; set; }
    }
    public class ProductResult
    {
        [JsonProperty("results")]
        public IEnumerable<Product> Results { get; set; }
    }
    public class Product
    {
        [JsonProperty("Title")]
        public string Title { get; set; }
        [JsonProperty("Price")]
        public float Price { get; set; }
    }

    The JsonConverter converts my JSON data into this object structure and I can easily then retrieve the actual Product results and return it my View.

    Modifying the View

    To display the set of products I use the built-in WebGrid in my Index View:

    <div class="row">
        <div class="col-md-4">
        @{
            WebGrid grid = new WebGrid(this.Model);
            @grid.GetHtml();
        }  
        </div>    
    </div>

    This will result in a grid view of my SharePoint products list like this:

    Wow, this dude has some serious UI skillz

    There you have it! This example can easily be extended with write operations or other stuff you would like to do, as long as you can express the requested permissions using the permission request XML.

    Summary

    In this post you have seen how we can leverage SharePoint data in other applications without using any user credentials and/or saved passwords. It requires minimal effort, especially when you’re using SharePoint Online (or ACS on-premises) since you only require Site Collection permissions to create the App Principal. All this thanks to the App Only policy.

  • Microsoft Azure IAAS and SharePoint 2013 tips and tricks

    Tags: Microsoft Azure, IAAS, SharePoint 2013, SQL Server

    After doing the Microsoft Cloud Show interview with Andrew Connell I thought it might be a good idea to write some of my tips and tricks for running SharePoint 2013 on Azure IAAS. Some of the stuff in this post are discussed in more depth in the interview and some things we just didn’t have time to talk about (or I forgot). I really recommend you to listen to the podcast as well and not just read this post.

    Disks, disks and disks

    As mentioned on the Microsoft Cloud Show interview more than once, one of the first things you should look into is your disk configuration for your Azure VM’s.

    Use a lot of disks

    One of the first things you must look into is the performance of disks. As you should be aware of SharePoint and SQL requires fast disks to operate with decent performance. When running an on-premises installation (virtual or physical) you have almost full control of the disk performance – you can choose from fast spinning disks to SSDs to different RAID configurations. But you cannot do that in Microsoft Azure. The virtual disks in Azure uses the blob storage for storing the VHD files, as blobs. Disk performance are often measured in IOPS (input/output operations per second) and in with the VHD files in the Azure blob storage we are limited to 500 IOPS per disk. Also worth noticing is that if you run the VM using the Basic tier offering, the limit is 300 IOPS per disk.

    TechNet contains a couple of article about calculating IOPS and the need for IOPS. For instance in the article called “Storage and SQL Server capacity planning and configuration (SharePoint Server 2013)” we can see that a content database requires up to 0.5 IOPS per GB. If we translate that into an Azure VHD we see that we can only have about 5 content databases per disk, assuming that they grow to 200GB each (a total of 1.000 GB). The Search Service Application, specifically the crawl and link databases has high IOPS requirements, so they should be on dedicated disks and so on. This is exactly the same as on any SharePoint installation – in the cloud or on your own metal. But the hard limit on 500 IOPS per VHD makes it even more obvious, given that we do not have a choice.

    So, when deciding which machine you are going to use for SharePoint and SQL, choose one with a lot of disks. For instance choose A4/A7 to get 16 disks or A3/A6 to get 8 disks.

    Read and Write caching

    A very important thing to configure for the Azure IAAS disks are the read and write caching, it is turned off by default on data disk – leave it like that!

    SQL Server Filegroups and multiple data files

    SQL Server has a concept called Filegroups which can be used to increase performance of databases. You can for a database in the primary file group add multiple data files and have them reside on different disks. (Thanks to Trevor Seward for the tip).

    Disk striping

    The maximum size of a VHD in Azure is 1TB (1.000GB), and the limitation is in the Azure blob storage. If you need larger volumes/disks in your Azure VMs then you need to stripe multiple disks into a single volume. Just add the VHDs and then use the Disk Manager to configure the disk striping.

    Disk size

    Create large disk files! You only pay for the space you actually use. If you store 1MB on a 500GB disk, you pay for 1MB. Reconfiguring disks cost you more!

    SQL specific stuff

    When running SQL on an Azure VM or any kind of virtual or physical hardware – do not forget to format the disk using 64K allocation unit size and do not forget to give the SQL Server service account “Perform Volume Maintenance Tasks” right. These two things makes a huge difference!

    Examples (and just examples nothing else!)

    For a single SQL Server this could look something like this:

    Disk/Volume Purpose
    1 OS (default)
    2 Temporary (default)
    3 SQL Server binaries
    4 Temp DB
    5 Temp DB log files
    6 Default SQL Server DBs
    7 Default SQL Server DB log files
    8 Search DBs
    9 Search DB log files
    10 Content DBs 1
    11 Content DBs 1 log files
    12 Content DBs 2
    13 Content DBs 2 log files
    14 Service Application DBs
    15 Service Application DB log files
    16 Backup 1

    And for a SharePoint machine it could look like this:

    Disk/Volume Purpose
    1 OS (default)
    2 Temporary (default)
    3 SharePoint binaries
    4 Blob cache
    5 Log files
    6 Index files
    7 ASP.NET Temporary files
    8 Tools
    9 Visual Studio (dev machine)
    10 Project files (dev machine)

    Note: do NOT store anything of value on the Temporary (default) disk, it will be wiped whenever Microsoft decides to. I would not even recommend storing SharePoint log files there (which I’ve heard recommendations of) since you might want to go back in time and search the logs eventually.

    Virtual Machine size

    Choosing the Virtual Machine size is one of the tricky questions; do you need RAM, CPU, Memory etc. “Fortunately” we do not have that much of a choice in Azure IAAS (compared to other vendors). We can choose from A0 to A9 – all the details here: “Virtual Machines Pricing Details”.

    If we’re talking about SharePoint and SQL we’re even further limited – A3 to A7 are the ones with sufficient RAM/CPU for that scenario, but we can almost exclude A5 which only has CPU two cores and only support 4 data disks. There is no “perfect machine” here, it depends. With regards to running SharePoint you might want a lot of cores for search machines etc etc. A4, A5 and A6 are good candidates for SharePoint in my opinion. A3 might do for a simple dev machine.

    Plan for High Availability

    Azure terminologyLet’s assume we’re setting up a SharePoint + SQL production environment in Azure, then you need to start to think about HA (High Availability). Part from the usual ways to do it (see my SPC 2014 presentation on the topic) there are a couple of other things that we must think of in Azure IAAS.

    Location

    Location should be fairly obvious. Do you want your stuff in North America, Asia, Northern Europe etc. It doesn’t have much with HA to do, but more about latencies and costs! Yes, if you want to be cost efficient check out the pricing in the different locations, it’s quite a difference.

    Affinity Groups

    Affinity Groups are a very important construct in Azure. Affinity Groups allows you to make sure that your cloud services, storage, virtual networks etc are placed “together”. Remember the data centers might be several football fields in size and you don’t want your machines scattered across all that space, that would only cause unwanted latencies. An Affinity Group makes sure that all your stuff in Azure are as close to each other as possible. Also this reduced our costs, since we don’t get any cross datacenter communication. An Affinity Group exists in one Location.

    Cloud Services

    “Cloud Services” are used in Azure to “group” instances together. Cloud Services have features such as end-points, load balancing and auto-scale. For SharePoint and SQL don’t even think about auto-scale though.

    It is very important to note that if you are using SQL Server Always-On Availability Groups, this SQL Server setup must be in its own Cloud Service, separate from the clients accessing it.

    Availability Sets

    Availability sets are a logical construct that allows you to specify a group of instances/roles. Whenever Microsoft must reboot one of your VMs for maintenance or other purposes, they will respect the Availability Sets and make sure that only one of the machines within an Availability Set are down at a time. For instance grouping all SharePoint Web Servers into one Availability Set, makes sense.

    An example

    Here is one example that I’ve shown when presenting this that gives you an idea of how an Azure IAAS SharePoint and SQL infrastructure might look like, once again just an example!

    SharePoint and SQL Azure IAAS example

    SQL Server optimizations

    I will not dig too deep into tips and tricks with SQL Server specifically but instead urge you to read the really good article “Performance Best Practices for SQL Server in Azure Virtual Machines”. That article gives you all the details and a nifty check list.

    Short notes

    Here are some other small things for you to remember:

    • Office Web Apps 2013/Office Online/WAC are NOT supported on Azure IAAS at the moment – hybrid with a site-to-site VPN is your way if you want WAC.
    • Always set your machine in High Performance mode .
    • If you’re using the public IP of the Cloud Service, remember to always have a machine running in that Cloud Service, otherwise the IP will change. Or use the Azure static DNS offering.
    • For development SharePoint machines and SQL – do not use the Azure SQL images, instead use your MSDN SQL Server Development Edition. If you don’t you will be billed for the SQL Server resource usage and that is even more expensive than running the actual VM.

    Summary

    That was a mouthful of tips and tricks and I hope you get something out of this. Of course there are plenty more, don’t be shy and use the comments for your best tips and tricks. I might update the post with your best tips or other things that I find. And also note, that these are in no way the official tips and tricks from Microsoft and the Azure Team, just my experience from working with it.

  • Interviewed on the Microsoft Cloud Show about Azure IAAS

    Tags: Microsoft Azure, SharePoint 2013, Interviews

    A couple of weeks back I was interviewed by Andrew Connell for the Microsoft Cloud Show. The Microsoft Cloud Show is an (almost) weekly podcast where Andrew (AC) and his wingman Chris Johnson (CJ) discusses everything related to Microsoft cloud offerings including benchmarks with other cloud vendors. If you’re not subscribing and listening to the show already then I urge you to do that as soon as possible!

    Microsoft Cloud Show

    Me and AC sat down for almost an hour discussing Microsoft Azure IAAS and specifically when running SharePoint 2013 in that service. We had a great talk, as usual when it comes to AC, and I think we covered a lot of the issues and gotchas and things to think about when building a SharePoint 2013 infrastructure on Azure IAAS.

    You can download and listen to Episode 40 of the Microsoft Cloud Show here. Enjoy!

  • How to check the version of AppFabric 1.1 aka the Distributed Cache

    Tags: AppFabric, SharePoint 2013

    Introduction

    The other day I posted about the patching procedure for the SharePoint 2013 Distributed Cache (Microsoft AppFabric 1.1) and on that post I got a great comment from Riccardo:

    Hi Wictor, is it possible to discover the patch level of the Distributed Cache without looking at control panel? Powershell?

    That is a great question Riccardo! But the answer is not that simple…

    Check the version using Installed Updates

    The easiest way to manually check what version of AppFabric you are using, or rather which CU that is applied to AppFabric 1.1, is to use the Program and Features tool in Windows Server and then click on View installed updates.

    Installed AppFabric updates

    As you can see in the screenshot above, they all have the same version 1.1.2106.32 and that is also the version you get when you query the registry with this:

    Get-ItemProperty HKLM:\SOFTWARE\Microsoft\AppFabric\V1.0\ -Name ProductVersion | select ProductVersion

    That version number is the version number of Microsoft AppFabric 1.1 and it doesn’t change when you are applying Cumulative Updates.

    Check the Distributed Cache version using PowerShell

    If you want to automate checking the patch level of the Distributed Cache then the only way I’ve found (if someone has a better way, please enlighten me) is to actually check the version of one specific file, the Microsoft.ApplicationServer.Caching.Configuration.dll file. This is one of the few files that is updated in all the current CU’s (1-5), but I cannot guarantee that it will be updated in future version. The check is is done using the following PowerShell script (remove the line breaks and paste as a single line):

    (Get-ItemProperty "C:\Program Files\AppFabric 1.1 for Windows Server\
    PowershellModules\DistributedCacheConfiguration
    \Microsoft.ApplicationServer.Caching.Configuration.dll" -Name VersionInfo)
    .VersionInfo.ProductVersion

    This script will give you different version numbers depending on your AppFabric 1.1 CU level as follows:

    CU level Product Version
    CU1 1.0.4639.0
    CU2 1.0.4644.0
    CU3 1.0.4652.2
    CU4 1.0.4653.2
    CU5 1.0.4655.2

    If this method is valid for future CU’s then please remind me to update this table.

    Summary

    So Riccardo, there you have the best answer I can give you. It is not an optimal solution but it works…

  • How to patch the Distributed Cache in SharePoint 2013

    Tags: SharePoint 2013, AppFabric

    Introduction

    In SharePoint 2013 the Distributed Cache plays a very important role, it is a key component for performance and caching. An incorrectly configured or managed Distributed Cache will cause issues, with your farm. I’ve even seen blogs recommending turning it off, most likely due to that they don’t manage the cache properly and get into a situation where it causes even worse performance problems. One of the good things with the Distributed Cache is that is not a SharePoint service, it is a standalone service called AppFabric 1.1 for Windows Server. Initially the guidance from Microsoft was that the Distributed Cache (DC) would be patched together with SharePoint and we should keep our hands off it. But that has over the time changed and allowed us to take advantage of the fixes and improvements that the AppFabric team does to the service. So, it is our responsibility to patch the Distributed Cache. But how do we do it?

    [Update 2014-07-16] Here's a link to the official statement that AppFabric/DC is independently updated from SharePoint: KB2843251

    Proper patch instruction

    First of all there are currently five released Cumulative Updates (CU) for AppFabric 1.1, CU1 to CU5. An AppFabric Cumulative Update is exactly the same as a CU for SharePoint, it contains all previous CUs. So if you install CU5 you also get CU1 to CU4 installed. The important thing with this is that you as an administrator should not just read the latest CU Knowledge base article, but also the previous ones (you will see one reason in a minute).

    Let’s assume that we have a SharePoint farm with more than one servers running the Distributed Cache service instance. To patch these we need to download the AppFabric CU that we would like to use. I’d recommend using the latest (CU5) right now and I’ve not yet seen any issues with it, only positive effects. If you are using Windows Server 2012 you definitely should go with at least CU4.

    Here’s a link to the different CU’s and their KB article respectively

    In this case let’s apply CU5.

    The first thing before patching that is really important to do is to properly shut down the Distributed Service instance. The reason that you would like to do this is that some items in the Distributed Cache is only living in the cache and is not backed to a persistent storage, such as some items in the SharePoint Newsfeed. If you do not properly shut down the service instance you will loose that data. Fortunately we have a great PowerShell cmdlet that does this job for us. The process here is that you need to patch one machine at a time according to these steps:

    1. Shut down the service instance on one machine
    2. Patch AppFabric 1.1
    3. Post-patch operations
    4. Start the service instance
    5. Restart from 1 on the next machine

    Do not do servers in parallel unless you have a massive amount of servers and can handle that extra load/redundancy!

    Step (1) is done in PowerShell using one of the built-in SharePoint cmdlets:

    asnp *sharepoint*
    Stop-SPDistributedCacheServiceInstance -Graceful

    This command will gracefully shut down the service instance on the local machine. A graceful shutdown means that all the cache items will be distributed to the other service instances in the cache cluster. Make sure that you have enough overhead to do this. This is yet another example of my “3 is the new 2” rule is important. When you patch one server you don’t want just one extra machine! Once the service instance is stopped, I normally wait a couple of extra minutes to make sure that all the cached items has properly propagated to the other servers.

    Then it is time to apply the actual AppFabric patch, step (2). Run the patch executable and follow the instructions. It’s basically a next, next, finish procedure.

    Step (3). When the patch is applied you should have read through the KB articles, and if you are applying CU3 or later you should have seen that in order to improve performance you need to modify the Distributed Cache configuration file. The CU3 KB article mentions a new feature added to the AppFabric service that takes advantage of the non-blocking background garbage collection feature in .NET 4.5, which is important for machines with large amounts of RAM – and that is exactly the description of a SharePoint server. So modify the DistributedCacheService.exe.config file as below to enable the background garbage collection:

    <configuration>
      ...
      <appSettings>
        <add key="backgroundGC" value="true"/>
      </appSettings>
    </configuration>

    The final thing we need to do on the machine is to start the service instance again, step (4). The AppFabric Windows Service will be disabled when it is shut down and you should NOT try to start that one manually, you must use the following PowerShell (or corresponding action in Central Administration if you’re a n00b).

    $instance = Get-SPServiceInstance | ? {$_.TypeName -eq "Distributed Cache" -and $_.Server.Name -eq $env:computername}
    $instance.Provision()

    This PowerShell snippet will get the Distributed Cache service instance on the machine where it is executed and provision it and start the AppFabric Windows Service.

    Once this is done and you are ready to move on to the next machine, step (5), give it a couple of extra minutes so that the newly patched (and empty) cache service instance has time to catch up.

    Not patching properly…

    A very common issue is that in order to apply the patch you just run the patch executable. Two things will happen when you do this. First of all the service will be shut down, but not gracefully and you will loose data. Secondly it will not start the service instance properly or at all. The patch contains a script that waits for the service to come online, but since this is not a normal AppFabric cache, it’s controlled by SharePoint, so this script will wait forever until the service comes up. If this happens all you have to do is kill the script window and start the service properly as shown above (warning: this is not a recommendation and there might be side effects)

    Summary

    I hope this short post cleared up some confusion on how to patch the Distributed Cache service in SharePoint 2013 and gave you an example on how to do this in a production environment without loosing any data. Of course, you should always test the procedure in a test/staging environment. Cache on!

About Wictor...

Wictor Wilén is a Director and SharePoint Architect working at Connecta AB. Wictor has achieved the Microsoft Certified Architect (MCA) - SharePoint 2010, Microsoft Certified Solutions Master (MCSM) - SharePoint  and Microsoft Certified Master (MCM) - SharePoint 2010 certifications. He has also been awarded Microsoft Most Valuable Professional (MVP) for four consecutive years.

And a word from our sponsors...

SharePoint 2010 Web Parts in Action