Azure IaaS for IT Pros Online Event (Dec 1-4)

Is it time to level up your skills using Infrastructure as a Service? Want to learn from the best technical engineers and noted technology leaders around?

Join Mark Russinovich, Corey Sanders, and members of the Azure Engineering team for a live event delivered online over four days. Join for one session, join for them all. You'll dive deep into technical scenarios, ask questions of the experts, and level up your own skills.

Azure IaaS for IT Pros Online Event, December 1-4
Click here to register!


Become an IaaS go-to guru
Mark Russinovich, Microsoft Chief Technology Officer, Azure, will kick off the event, followed by deep technical training in the technologies critical for IT Pro Implementers, like you, to deepen your foundational cloud skills. Following the keynote, experts will share their technical insights on topics including Core IaaS, Cloud Infrastructure Fabric, Open Source Software on Azure, and Workloads on Azure IaaS.

Be recognized for your skills
Get certified for your skills! Register for the event to receive reminder emails and obtain details for receiving a 50% off exam voucher you can use towards Exam 70-533: Implementing Microsoft Azure Infrastructure Solutions for Microsoft Azure Specialist Certification.

Join the live event from 9am to 1pm PST

December 1
Establish the Foundation: Core IaaS Infrastructure Technical Fundamentals

December 2
Dive Deep into Networking, Storage, and Disaster Recovery Scenarios

December 3
Embrace Open Source Technologies (Chef and Puppet Configurations, Containerization with Docker and Linux) to Accelerate and Scale Solutions

December 4
Optimize Windows Workload Architecture and Administration Capabilities Within Azure

Register Now

“Object already exists” error during Release Management server configuration

I was getting the following error while configuring RM server - "Object Already exists". Please find the log.

Database ReleaseManagement, version 12.0.30XXX.0 was installed successfully.

Created Release Management database.

Received Exception : System.Security.Cryptography.CryptographicException: Object already exists.

at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)

at System.Security.Cryptography.Utils._CreateCSP(CspParameters param, Boolean randomKeyContainer, SafeProvHandle& hProv)

at System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer)

at System.Security.Cryptography.Utils.GetKeyPairHelper(CspAlgorithmType keyType, CspParameters parameters, Boolean randomKeyContainer, Int32 dwKeySize, SafeProvHandle& safeProvHandle, SafeKeyHandle& safeKeyHandle)

at System.Security.Cryptography.RSACryptoServiceProvider.GetKeyPair()

at Microsoft.TeamFoundation.Release.CommonConfiguration.Helpers.CryptoHelper.ConfigureServerCryptoKey(String serverName, String databaseName)

at Microsoft.TeamFoundation.Release.Configuration.ConfigurationManager.Configure(ConfigurationUpdatePack updatePack, DelegateStatusUpdate statusListener)

at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)

Work completed for GetConfiguration() call : got out of turn error

Object already exists.

 

To fix the problem, you need to make sure that the credentials used to configure the Release Management server has modify permissions on C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys. You might have to take ownership of some of the files within that folder before you can grant yourself modify permissions.

Deploy SharePoint solution in Release Management

Here is another PowerShell script that can help you deploy SharePoint solutions using Release Management. This PowerShell script can be used as a part of a custom tool/action/component in Release Management that will deploy (or first retract, then deploys) a SharePoint solution. It's fairly straightforward script that might not necessarily cover every possible scenario in SharePoint solution deployment, but it works. It takes three parameters: name of the SharePoint solution, web application name, and compatibility level of the solution. Script assumes that the wsp file is located in the same folder as the PowerShell. I know it's not perfect, but it can be easily modified to use full path to the wsp file instead.

param

(

[string]$WebApp = $null,

[string]$WSP_FileName = $null,

[string]$CompatibilityLevel = $null

)

 

function WaitForJobToFinish([string]$Identity)

{

$job = Get-SPTimerJob | ?{ $_.Name -like "*solution-deployment*$Identity*" }

$maxwait = 30

$currentwait = 0

if (!$job)

{

Write-Host -f Red '[ERROR] Timer job not found'

}

else

{

$jobName = $job.Name

Write-Host -NoNewLine "[WAIT] Waiting to finish job $jobName"

while (($currentwait -lt $maxwait))

{

Write-Host -f Green -NoNewLine .

$currentwait = $currentwait + 1

Start-Sleep -Seconds 2

if (!(Get-SPTimerJob $jobName)){

break;

}

}

Write-Host -f Green "...Done!"

}

}

 

function RetractSolution([string]$Identity, [string]$web_application, [string]$compatibility_level)

{

Write-Host "[RETRACT] Uninstalling $Identity"

Write-Host -NoNewLine "[RETRACT] Does $Identity contain any web application-specific resources to deploy?"

$solution = Get-SPSolution | where { $_.Name -match $Identity }

if($solution.ContainsWebApplicationResource)

{

Write-Host -f Yellow "...Yes!"

Write-Host -NoNewLine "[RETRACT] Uninstalling $Identity from $web_application web application"

Uninstall-SPSolution -identity $Identity -CompatibilityLevel $compatibility_level -WebApplication $web_application -Confirm:$false -ErrorVariable uninstallSolution

}

else

{

Write-Host -f Yellow "...No!"

Uninstall-SPSolution -identity $Identity -Confirm:$false

}

if ($uninstallSolution.Count -ne 0)

    {

        throw "Uninstalling SharePoint solution failed."

    }

else

{

Write-Host -f Green "...Done!"

}

WaitForJobToFinish

Write-Host -NoNewLine '[UNINSTALL] Removing solution:' $SolutionName

Remove-SPSolution -Identity $Identity -Force -Confirm:$false -ErrorVariable removeSolution

if ($removeSolution.Count -ne 0)

    {

        throw "Removing SharePoint solution failed."

    }

else

{

Write-Host -f Green "...Done!"

}

}

 

function DeploySolution([string]$Path, [string]$Identity, [string]$web_application, [string]$compatibility_level)

{

Write-Host -NoNewLine "[DEPLOY] Adding solution:" $Identity

Add-SPSolution $Path -ErrorVariable addSolution

if ($addSolution.Count -ne 0)

        {

            throw "Adding SharePoint solution failed."

        }

else

{

Write-Host -f Green "...Done!"

}

Write-Host -NoNewLine "[DEPLOY] Does $Identity contain any web application-specific resources to deploy?"

$solution = Get-SPSolution | where { $_.Name -match $Identity }

if($solution.ContainsWebApplicationResource)

{

Write-Host -f Yellow "...Yes!"

Write-Host -NoNewLine "[DEPLOY] Installing $Identity for $web_application web application"

Install-SPSolution -Identity $Identity -CompatibilityLevel $compatibility_level -WebApplication $web_application -GACDeployment -Force -ErrorAction Stop -ErrorVariable installSolution

}

else

{

Write-Host -f Yellow "...No!"

Write-Host -NoNewLine "[DEPLOY] Globally deploying $Identity"

Install-SPSolution -Identity $Identity -GACDeployment -Force -ErrorAction Stop -ErrorVariable installSolution

}

    if ($installSolution.Count -ne 0)

    {

        throw "Installing SharePoint solution failed."

    }

else

{

Write-Host -f Green "...Done!"

}

WaitForJobToFinish

}

 

$snapin = Get-PSSnapin | Where-Object { $_.Name -eq "Microsoft.SharePoint.Powershell" }

if ($snapin -eq $null) {

Write-Host "[INIT] Loading SharePoint Powershell Snapin"

Add-PSSnapin "Microsoft.SharePoint.Powershell"

}

 

$identity = $WSP_FileName

$path = $WSP_FileName

Write-Host "[INFO] ----------------------------------------"

Write-Host "[INFO] Installing $Identity"

Write-Host -NoNewLine "[INFO] Determining if $Identity is already installed"

 

$isInstalled = Get-SPSolution | where { $_.Name -eq $identity }

if ($isInstalled)

{

Write-Host -ForegroundColor Yellow "...Yes!"

(RetractSolution $identity $WebApp $CompatibilityLevel)

(DeploySolution $path $identity $WebApp $CompatibilityLevel)

}

else

{

Write-Host -ForegroundColor Yellow "...No!"

(DeploySolution $path $identity $WebApp $CompatibilityLevel)

}

Write-Host -NoNewline "[INFO] Installation and deployment of $Identity"

Write-Host -ForegroundColor Green "...Done!"

 

##################################################################################

# Indicate the resulting exit code to the calling process.

if ($exitCode -gt 0)

{

"`nERROR: Operation failed with error code $exitCode."

}

"`nDone."

exit $exitCode

 

Here is a link to download the script.

Backup SharePoint solution before deploying its new version using Release Management

Just wanted to share the PowerShell script to backup SharePoint solutions using Release Management. This script can be used as a part of a custom tool/action in Release Management that will backup existing SharePoint solution before deploying a new version of this solution. This tool/action could come in handy when you would like to set up rollback activities for when SharePoint solution install goes sideways. I think it's a good idea to back up things. You know, just in case…

Here is a script. It's not the most sophisticated PowerShell script, but it gets the job done. It takes two parameters: name of the SharePoint solution and the destination folder where you would like to store the backed up solution file.

param

(

[string]$WSP_FileName = $null,

[string]$DestinationName = $null

)

# Load SharePoint snap-in

$snapin = Get-PSSnapin | Where-Object { $_.Name -eq "Microsoft.SharePoint.Powershell" }

if ($snapin -eq $null) {

Write-Host "[INIT] Loading SharePoint Powershell Snapin"

Add-PSSnapin "Microsoft.SharePoint.Powershell"

}

 

Write-Host "[INFO] ----------------------------------------"

Write-Host "[INFO] Backing up $WSP_FileName"

$farm = Get-SPFarm

$file = $farm.Solutions.Item("$WSP_FileName").SolutionFile

$BackupPath = Join-Path $DestinationName $WSP_FileName

if ($file.Count -ne 0)

    {

$file.SaveAs("$BackupPath")

Write-Host -f Green "...Backup complete!"

    }

else

{

    throw "$WSP_FileName solutiuon was not found."

}

 

##################################################################################

# Indicate the resulting exit code to the calling process.

if ($exitCode -gt 0)

{

"`nERROR: Operation failed with error code $exitCode."

}

"`nDone."

exit $exitCode

 

Here is a link to download the script.

Replace a string in a file with PowerShell

I have wanted to expand my PowerShell skills for some time, however I find it a steep learning curve. One thing I am learning is the result is worth it.

I recently needed to replace a string in a file. I searched a found the working parts I needed create this. I just wanted to post it here so I know where to come back and find it.

 

[CmdletBinding()]

param

(

    [Parameter(Mandatory=$True)]

    [string]$OldValue,

    [Parameter(Mandatory=$True)]

    [string]$NewValue,

    [Parameter(Mandatory=$True)]

    [string]$FilePath

)

(Get-Content $FilePath) |

Foreach-Object {$_ -replace "$OldValue","$NewValue"|

set-content $FilePath

 

A wonderful addition to this is you can even pop regular expressions into the $OldValue.

 

(Get-Content MySSAS.deploymenttargets) |

Foreach-Object {$_ -replace "<Server>(.*?)</Server>","<Server>__TargetDataBase__</Server>"}  |

set-content MySSAS.deploymenttargets

 

 

 

Release Stuck in Pending State

Recently, I have come across an interesting behavior in TFS Release Management. When you kick off new release, the release gets stuck in Pending state on certain custom components. And, it stays in that state "forever". Obviously, the first thing that comes to mind is that deployment agent is not responding (even though it does not really make sense since if the agent became unresponsive the component deployment task would time out eventually), but you go ahead and try to restart the deployment service running on the target server anyways. It does not help, of course. So, you start taking other "desperate" measures like re-configuring deployment agent or restarting the target server, but nothing works. I'm calling those measures "desperate" because, deep down in your heart, you know that there is nothing wrong with the target server and that the problem lies somewhere else. You just don't know where, so you resort to the old "Have you tried turning it off and on" approach. We all do it...

Anyways, after a bunch of digging around, I have finally discovered a pattern when this problem occurs. Imagine the following scenario:

  1. You create a custom component and add it to your release template
  2. You kick off your release template
  3. You then realize that you need to tweak your custom component, so you go ahead and tweak your custom component, then kick off your release template again with your recent changes to the component.

This is a very typical continuous improvement approach. You make a change to your custom component, save it and the next time release has been triggered your changes to component will take effect. It works every time in Release Management. Well, almost every time. Apparently, if you change one of the configuration variables in your components from Standard type to Encrypted type (and vice versa), save your component and trigger release, then the release will get stuck in Pending state on that component. Not sure why this is happening. Perhaps, the hash of the component changes or something. Anyways, to fix the issue, you need to:

  1. Remove the component in question completely from your release template, including a link to the component. Then, save the release template
  2. Reopen release template and re-link the component in question
  3. Re-add the component in question, and re-enter the values for your configuration variables.
  4. Save the release template
  5. Trigger a new release. Release should now successfully deploy the component in question

To me, this looks like a bug to me and, hopefully, Microsoft will address this in the next update(s) of the Release Management Server. I am sure they will.

P.S.: This is my first blog post as a Microsoft MVP in Visual Studio ALM. Looking forward to writing a lot more… Hurray!!!

Separate TFS Build Server Output into Different Folders

TFS 2013 makes it easier to separate build server output to different folder. In most of the cases, all you have to do is to change Output Location setting in build definition. Output Location setting can be set to the following values:

  • SingleFolder to place all the build output files together in the drop folder.
  • PerProject to group the build outputs into drop folder sub-folders for each solution or code project that you have specified in the Projects box.
  • AsConfigured to leave the binaries in the build agent sources folder, organized into the same sub-folder structure you see when you build your code on your dev machine in Visual Studio. This structure is defined in your code projects.
  • If you use this option, TFBuild will not copy the output to the drop folder. Instead, you can program your scripts to copy the outputs to the location specified by TF_BUILD_BINARIESDIRECTORY so that they get dropped to the staging location. See post-build or post-test scripts.

This is a great feature/setting in TFS 2013 and it works every time. Well, almost every time. PerProject setting is a bit misleading because it does not always group the build outputs per project. In cases, when you choose to build multiple solutions which consists of multiple projects, TFS Build server will split solutions into its different folders. Project output will not be output into separate folders and instead the output for all projects in the solution will be stored in a single folder. Even though your build definition Output Location is set to PerProject. Frustrating. L

To separate project output into different folder when building multiple solutions, you need to set GenerateProjectSpecificOutputFolder MSBuild property to True. To be more precise, set MSBuild arguments setting to /p:GenerateProjectSpecificOutputFolder=True and projects will automatically build into different subfolders. Voila!

Visual Studio Test Manager 2013 does not record actions

We have noticed that Visual Studio Test Manager 2013 behaves differently on some of the machines. More precisely, it does not record actions on some of the machines, while it works perfectly fine on the other machine while running the same test plan under the same test settings. All machines were running Windows 7 with the same version of Visual Studio installed. User tried rebooting the machine, clearing cache, you know the usual stuff. Nothing helped. This is where I stepped in. J

After a bit of digging, I have noticed that Visual Studio Test Manager 2013 is running fine on 32-bit installs of Windows 7. Visual Studio Test Manager was also running fine when users were running 32-bit of Internet Explorer instead of 64-bit version. Then, I have remembered that Visual Studio Test Manager 2013 does not support 64-bit version of Internet Explorer for recording and playback (see http://msdn.microsoft.com/en-ca/library/dd380742.aspx for more info.) So, as long as users are using 32-bit version of Internet Explorer (C:\Program Files (x86)\Internet Explorer\iexplore.exe) instead of 64-bit version of Internet Explorer (C:\Program Files\Internet Explorer\iexplore.exe) everything is working as it should. Problem solved. Sort of.

Creating new websites using TFS Release Management

When you use TFS Release Management server to deploy your builds to various (and you really should because it's awesome), you might have tried to get it to do all kinds of stuff like automate Windows operations, IIS actions, registry modifications, services manipulations and so on and so forth. Beautiful, right? Yes, I like it too. Release Management is a great piece of software that will not get better. And, in an effort, to make this software better, I wanted to share a small bug I have discovered in the software.

When you use Create Website action to create a new website in IIS, Release Management seem to create website just fine, but if you look closer you might notice a bug. When Release Management action created a website in IIS, it will misconfigure physical path assigned to the website. Unless you set IsAutoStart option to true, and leave IsPreloadEnabled option blank (unless, of course, you use IIS8 or better.) The reason why this is happening is that when Release Management action creates a website it is using iisconfig.exe command. And, for some reason, it's messing up the syntax unless you set those two options. So, for now, just set set IsAutoStart option to true, and leave IsPreloadEnabled option blank. And, hopefully, Microsoft will fix that bug in the future release…

Making Template Changes to the Projects Migrated from Visual Studio Online

So, you have migrated TFS projects from Visual Studio Online and now you want to make certain improvements to newly migrated projects. Well, you're out of luck. When you try to customize work item types of the existing TFS projects migrated from the cloud, you will receive an error. Even though you have all the necessary permissions. So, what exactly is the problem here?!? Apparently, there is something in the migration process that causes certain metadata missing from security tables when TFS contents are moved from Visual Studio Online to the on-premises servers. As a result TFS simply does not know that you're now allowed to modify the project template.

To solve the problem, you will have to call Microsoft technical support. They will send you the fix. Hopefully, they will integrate that fix into the migration, so this kind of think does not happen. Hopefully…