Failed to bring availability group ” online

Recently, I was installing a SQL Server Availability Group on two VMs to verify some open questions I had. And I am surprised that the installation went pretty smoothly. But when I tried to create the availability group I got the following error message.

Failed to bring availability group ‘<availability group name>’ online. The operation timed out. Verify that the local Windows Server Failover Clustering (WSFC) node is online. Then verify that the availability group resource exists in the WSFC cluster. If the problem persists, you might need to drop the availability group and create it again.    

The message seemed to be pretty precise and I started verifying my WSFC configuration but unfortunately I couldn’t find any mistakes there. After searching for a while I found the following support post: http://support.microsoft.com/kb/2847723 It describes exactly my problem and the only thing I had to do was executing the following script:

USE [master]
GO
CREATE LOGIN [NT AUTHORITY\SYSTEM] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO

GRANT ALTER ANY AVAILABILITY GROUP TO [NT AUTHORITY\SYSTEM]
GO
GRANT CONNECT SQL TO [NT AUTHORITY\SYSTEM]
GO
GRANT VIEW SERVER STATE TO [NT AUTHORITY\SYSTEM]
GO

It fixed the problem and I was able to create my availability group without any problems.

PowerShell – wait for completion of external process

Often when working with PowerShell you want to start an external process and wait for its completion. An example of this might look like this:

Write-Host "Show before starting Notepad"

Notepad.exe

Write-Host "Show after closing Notepad"

But this script prints the second line directly after starting notepad. There are several solutions possible, but this one has proved very useful.

Write-Host "Show before starting Notepad"

Notepad.exe | Out-Null

Write-Host "Show after closing Notepad"

Simply add Out-Null after the invocation of notepad and PowerShell will wait until it continues executing the script.

Failed to bring availability group ‘[availability group name]‘ online

Recently, I was installing a SQL Server Availability Group on two VMs to verify some open questions I had. And I am surprised that the installation went pretty smoothly. But when I tried to create the availability group I got the following error message.

Failed to bring availability group ‘<availability group name>’ online. The operation timed out. Verify that the local Windows Server Failover Clustering (WSFC) node is online. Then verify that the availability group resource exists in the WSFC cluster. If the problem persists, you might need to drop the availability group and create it again.    
 
The message seemed to be pretty precise and I started verifying my WSFC configuration but unfortunately I couldn’t find any mistakes there. After searching for a while I found the following support post: http://support.microsoft.com/kb/2847723 It describes exactly my problem and the only thing I had to do was executing the following script:
USE [master]
GO
CREATE LOGIN [NT AUTHORITY\SYSTEM] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
 
GRANT ALTER ANY AVAILABILITY GROUP TO [NT AUTHORITY\SYSTEM]
GO
GRANT CONNECT SQL TO [NT AUTHORITY\SYSTEM]
GO
GRANT VIEW SERVER STATE TO [NT AUTHORITY\SYSTEM]
GO
 
It fixed the problem and I was able to create my availability group without any problems.

SecureStore Provider default implementation for SharePoint 2013

From time to time,  you need to add some credentials to the SharePoint secure store. Depending on the type of credentials you enter, you also need to provide the SecureStore Provider implementation. If you are simply using the default implementation, you also need to provide a value because SharePoint does not allow you to leave that field empty. Just enter the following value for the SecureStore default implementation:

Microsoft.Office.SecureStoreService.Server.SecureStoreProvider, Microsoft.Office.SecureStoreService, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c

Setting up TFS Build Server for SharePoint 2013

Having a build server to compile all checked in code is a very useful thing but preparing the build server for SharePoint 2013 projects requires a few steps (applicable for TFS 2010 and TFS 2012). In order to complete it, you need to have a SharePoint development machine to copy the assemblies from.

  1. Run the SharePoint Prerequisites Installer in order to install all dependency (like Windows Identity Foundation etc.)
  2. Open the GAC on the development machine (C:\Windows\Microsoft.NET\assembly\GAC_MSIL\ ) and copy the following assemblies:
    • Microsoft.Office.SecureStoreService
    • Microsoft.VisualStudio.SharePoint
    • Microsoft.VisualStudio.SharePoint.Commands.Implementation.V5
    • Microsoft.VisualStudio.SharePoint.Designers.Models
    • Microsoft.VisualStudio.SharePoint.Designers.Models.Features
    • Microsoft.VisualStudio.SharePoint.Designers.Models.Packages
    • Microsoft.VisualStudio.SharePoint.ProjectExtensions.CodeGenerators
    • Microsoft.VisualStudio.SharePoint.Remote
    • Microsoft.VisualStudio.SharePoint.Wsp
  3. Copy all SharePoint related assemblies from C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI to C:\Program Files\Reference Assemblies\SharePoint\ on the build server
  4. Open the registry path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.5.50709\AssemblyFoldersEx and add the following key: SharePoint15]@=”C:\Program Files\Reference  Assemblies\SharePoint\”
  5. Copy the folders SharePointTools,Web, WebApplications from C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0  to the corresponding path on the build server
  6. Copy the file C:\Program Files\Common Files\Microsoft Shared\web server extensions\15\TEMPLATE\XML\appManifest.xsd to the corresponding path on the build server (only necessary if you want to build SharePoint 2013 Apps)

Hint: This tutorial assumes that the TFS binaries are installed and the build server is already connected to a TFS. The required steps are listed here: http://msdn.microsoft.com/en-us/library/hh395023.aspx

Suppressing Code Analysis warnings in Entity Framework generated code

When using Entity Framework Database First it can happen that the code generated by the edmx file causes Code Analysis errors. This happens due to the fact that the t4-template misses the GeneratedCode attribute. It is pretty easy to modify the template to contain the necessary attributes.

Modify the context template

  1. Add using System.CodeDom.Compiler; at the right position in the using directives
  2. Add [GeneratedCode("EntityModelCodeGenerator", "4.0.0.0")] above the class declaration line

Modify the template of the model classes

  1. Find EntityClassOpening and modify to the return a string starting with the GeneratedCode attribute
  2. Find <#=codeStringGenerator.UsingDirectives(inHeader: false)#> and add  below using System.CodeDom.Compiler;

Unable to access T-SQL components & An incompatible DacFx version is installed

After trying to view data from within Visual Studio to error messages appear:

Unable to access T-SQL components

An incompatible DacFx version is installed

Some might have seen this error before and the reason is quite simple. The installed Data-Tier Application Framework version and SQL Server Data Tools do not match the ones required by the database.

Just install the latest version from here:

SSDT: http://msdn.microsoft.com/en-us/data/hh297027

DacFx: http://www.microsoft.com/en-us/download/details.aspx?id=35756

And everything is working fine again.

Update: 

Apparently the old link does not work any longer. This is the working download link for DacFx 2012. http://www.microsoft.com/en-us/download/details.aspx?id=36842