I wanted to create a Node.js cloud application for Windows Azure platform. Current support is limited to PowerShell based user experience for creating and publishing a Node.js cloud app to Windows Azure. See the Node.js application creation tutorial.

I ran into the issue where the publish PowerShell command-let, Get-AzureSettings, failed. I already had 10 management certificates for my Windows Azure subscription and it appears that the command-let tries to create a new certificate for generating the publishsettings file. This is weird since I already have a management certificate for uploading packages via Visual Studio. 

I didn’t have any unneeded certificates that I could delete. So, this was clearly a blocker for me and pushed me to look for a Visual Studio based solution. Visual Studio already supports cloud apps creation and publishing (without requiring creation of additional certificates). It seemed that there should be an easy hookup for supporting Node.js. Apparently, it was not super easy and straightforward, however after jumping through a few hoops, I managed to get Visual Studio create the Node.js application package. I was able to test the application package in DevFabric as well as publish the app to the Cloud. I hope you find this information useful.


Issues addressed


  1. Get-AzurePublishSettings creates 1 management certificate for each of my subscriptions, even though I may deploy the application to the first subscription only. It probably does that to provide support for deploying the package to any of the subscriptions. It is a crappy assumption since all my subscriptions now have a certificate that is essentially useless for reuse elsewhere (Visual Studio).
  2. Get-AzurePublishSettings command-let fails if I already have 10 certificates in my subscription. The error is:
    1. “You have reached your quota of 10 management certificates and cannot add any more. Visit the Management Portal to delete any unneeded certificates.”
    2. What do I do if I don’t have any unneeded certificates to delete!!
  3. There is no way for me to use an existing management certificate with Publish-AzureService command-let.

Pre-requisites


Ensure that you have the following prerequisites installed on the computer:

  1. Windows Azure SDK for .NET – download link
  2. Windows Azure SDK for Node.js – download link

Environment


I used the following development environment:

  1. Windows Server 2008 R2 SP1
  2. Visual Studio 2010 Professional SP1

Initial setup


  1. Open a Node.js PowerShell command prompt via start > All Programs > Windows Azure SDK for Node.js – November 2011 > Windows Azure PowerShell for Node.js > Right click > Run as Administrator
  2. Start Visual Studio. File > New Project … .New Project dialog box pops up
  3. Select Visual C # > Cloud in Recent Templates pane on the left. Select Windows Azure Project template in the middle pane, click OK.
  4. New Windows Azure Project dialog box pops up.
  5. Select ASP.NET Web Role and click on right arrow button. Click OK.
  6. Visual Studio may prompt to install Visual Studio extension NuGet. Click OK to install the extension.
  7. Delete Account, App_Data, Scripts, Styles, *.aspx, Global.asax, Site.Master, Web.config (Web.Debug.config, Web.Release.config), WebRole.cs files and folders from WebRole1 project. What you have is an empty webrole to which we will add Node.js capabilities in the next section.
  8. Assume that the project name is WindowsAzureProject1, WebRole name is WebRole1 [Replace these names with the actual names from your project].

The conversion


  1. In the Node.js PowerShell command prompt, run commands
    1. cd c:\temp
    2. New-AzureService tempService
    3. Copy tempService\*.* <project folder>\WindowsAzureProject1\WebRole1
    4. Add-AzureNodeWebRole WebRole1
    5. npm install azure
    6. xcopy /chedi .\WebRole1\. <project folder\WindowsAzureProject1\WebRole1\.
  2. In Visual Studio, add server.js, Web.cloud.config, Web.config files to the WebRole1 project
  3. Add a reference to c:\windows\assembly\GAC_64\1.6.0.0__31bf3856ad364e35\msshrtmi.dll. Set Copy local property to True.
  4. Manually add the following to <project folder>\WindowsAzureProject\WebRole1\WebRole1.csproj file. For all these binaries, set Copy Local to False.

    <ItemGroup>
      <Content Include="bin\node.exe" />
      <Content Include="bin\vcredist_x64.exe" />
      <Content Include="bin\iisnode.msi" />
      <Content Include="bin\setup_web.cmd" />
    </ItemGroup>

  5. Now you are ready to build, package, deploy, debug the <project folder>\WindowsAzureProject1 as a regular cloud app in Visual Studio. 
  6. And did I mention that you won’t be required to create a new management certificate for all your subscriptions for packaging and publishing the application to Windows AzureSmile. You can use the existing management certificate that you have imported for use with Visual Studio publishing.


THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

Copyright (C) 2011 Vikas Tyagi. All rights reserved.