Not able to upload Role after upgrading the SDK

I recently worked on an issue where the following error was being thrown while deploying the upgraded role to Windows Azure. You just upgraded the SDK to 2.1 or 2.2 and you start getting the following error while deploying the role.

 

10/26/2013 7:01:33 AM - Connecting...
10/26/2013 7:01:35 AM - Verifying storage account 'myStorage'.
10/26/2013 7:01:36 AM - Uploading package...
10/26/2013 7:01:42 AM - Upgrading...
The polling operation Upgrade Deployment failed with the error: (400) BadRequest.
Error Code: BadRequest
Message: The feature named NetFx451 that is required by the uploaded package is not available in the OS * chosen for the deployment.
Upgrade Failed for the Staging Slot of the myupdatedworkerrole Hosted Service. The existing deployment will be deleted and the new deployment will be deployed.
10/26/2013 7:02:26 AM - Creating...
The polling operation Create Deployment failed with the error: (400) BadRequest.
Error Code: BadRequest
Message: The feature named NetFx451 that is required by the uploaded package is not available in the OS * chosen for the deployment.
The deployment failed. Check the logs for exceptions that may have caused this failure.
 Associate Changesets and Work Items
 Exception Message: An attempted http request against URI returned an error: (400) BadRequest.
 Additional Exception Information:
 Error Code: BadRequest
 Message: The feature named NetFx451 that is required by the uploaded package is not available in the OS * chosen for the deployment. (type AzureHttpRequestException)
 Exception Stack Trace: at System.Activities.Statements.Throw.Execute(CodeActivityContext context)
at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager)
at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation) 

Based on my discussion with customer I found that the issue started happening after SDK was upgraded from 1.7 to 2.1. NetFx is nothing but a fancy name for .Net Framework. So I checked the configuration file and found the OS Family set to 2.

As per our MSDN documentation https://www.microsoft.com/en-us/download/details.aspx?id=39708

Supported Operating Systems for .Net 4.5 are as below.

Windows 7 Service Pack 1, Windows 8.1, Windows 8.1 Preview, Windows Server 2008 R2 SP1, Windows Server 2008 Service Pack 2, Windows Server 2012

So Windows 2008 R2 (OS 2) should have .Net 4.5 and it should support SDK 2.1 . We modified the ServiceConfiguration.Cloud.cscfg to osFamily="3" osVersion="*" . But it still failed with the same error. And based on further analysis I found that customer's machine where the project was rebuilt had VS2013.  

So I checked the article https://msdn.microsoft.com/en-us/library/bb822049.aspx . It seems .Net 4.5.1 is the default for Visual Studio 2013. So I relooked at the error and it actually has NetFx451. Same article specifies that only Windows Server 2012 R2 will have .NET Framework 4.5.1

So we changed the ServiceConfiguration.Cloud.cscfg to osFamily="4" osVersion="*" and redeployed the role and this time it came up fine without any errors. The changes were pushed the changes to TFS online and checked in, and then the deployment option was used to upgrade the role. The roles recycled and came up fine again without any issues. Tested the worker role and it is picking up the jobs from the queue and processing so it's working fine

This blog is credited to my customer who insisted he didn’t get any hits when he searched on the internet with the error message and wanted me to blog about this issue to help other customers who might hit the same issue when upgrading the Windows Azure SDK.

 

Angshuman Nayak, Cloud Integration Engineering