Error in Fixit Demo: Cannot get Azure subscription ID and thumbprint, urghh

In case you are working through the excellent book: “Building Cloud Apps with Microsoft Azure”, this is an excellent introduction to the programming and use of Azure.  If you are using the FixIt demo from the Code Gallery, which are the code samples from the free e-Book: Building Real-World Cloud-Apps with Microsoft Azure

This book will start from basic principles that are being used in the sample code on the website https://Azure.Microsoft.Com tutorials

Problem that you might encounter:

However, getting the sample to work has a few problems. The main problem you might run into is this error:

Error: Cannot get Azure subscription ID and thumbprint. Failed in New-FirewallRuleForWebsite in New-AzureSql.ps1
At C:\myfixit\C#\automation\New-AzureSql.ps1:197 char:47
+     if (!($subscriptionID -and $thumbprint)) {throw "Error: Cannot get Azure sub ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (Error: Cannot g...ew-AzureSql.ps1:String) [], RuntimeException
    + FullyQualifiedErrorId : Error: Cannot get Azure subscription ID and thumbprint. Failed in New-FirewallRuleForWebsite in New-Az


The solution is fairly obvious to some, invisible to powershell beginners or those who might not have read the instructions on using the powershell function Get-AzureSubscription.  The Get-AzureSubscription is used the FixIt Demo powershell scripts: New-AzureSql.ps1 and the New-AzureWebsiteEnv.ps1, which are provided in the FixIt Demo download.  To fix the error you might do the following, I am not sure if there is another solution, but I know this works:

  • In the code you will have a line:
    • $s = Get-AzureSubscription –Current
  • Change that line to:
    • $s = Get-AzureSubscription -Current –ExtendedDetails
  • The difference between the two lines is that the –ExtendedDetails will return the Thumbprint required by the code

Most of the solutions are also explained in the related Code Gallery item Q&A:

Other initial issues you might encounter

Exceeding server quota

Next, because you have been trying things, you might have created more than 6 Azure SQL Database servers, NOT databases, so take a look at a previous blog to quickly fix this problem.  In this case I am not sure that you can fix this problem from within the portal, you have to use powershell for many of the Azure subscription types:

Running the code

You might miss that there is a powershell to deploy the code to the Azure Website, this powershell filename is Publish-AzureWebsite.ps1.  The powershell script is looking for the MyFixIt.csproj, not the solution file with the extension *.sln.  Also, you will encounter some latency on when the website will show up in your browser.