by jnak via Cloudy in Seattle on 11/18/2009 11:00:00 PM
Thanks to everyone who attended my session at PDC today. I really hope that you took something useful away from it.
As mentioned in the session, I’m posting the set of tips that were covered.
You can now view the session online at: http://microsoftpdc.com/Sessions/SVC53
If you missed my session, I went through a "green field" new Windows Azure Cloud Service project developer scenario as well as a "brown field" moving an existing ASP.NET web application to run on Windows Azure developer scenario.
Through the context of those two walkthroughs, I covered the following Tips and Tricks.
Tips for Getting Started
1. The Web Platform Installer automates a number of the steps to install the Windows Azure Tools for VS 2008 or to install IIS prior to installing the Windows Azure Tools for VS 2010.
2. Get the patches - http://msdn.microsoft.com/en-us/azure/cc974146.aspx
3. Name your projects before creating them. When you add roles to your cloud service solution, it is much easier to rename them at that stage, then after the solution and projects have been created.
The reason is that even though you can use the Solution Explorer to rename the projects after creation, the folders where those projects reside will not be renamed.
4. Include the Static Content module and register the Silverlight mime type in IIS – I actually didn’t mention this one (on purpose) in my session as it fell below the cut line but the development fabric uses IIS under the hood and every so often we run into folks that get unexpected results when they run their apps on IIS because they are used to running them on the ASP.NET Development Server.
To enable the static content module: See tip #1 above (use WebPI) or see this article http://technet.microsoft.com/en-us/library/cc732612(WS.10).aspx
To register the xap mime type (typically only needed for older OSs):
If you are using WCF, don’t forget to install the WCF Activation Windows feature – Control Panel | Programs | Turn Windows features on or off | Microsoft .NET Framework 3.5.1 | Windows Communication foundation HTTP Activation
Tips During Development
5. Always keep the Cloud Service project as the StartUp project to get the desired Run/Debug on the development fabric behavior.
5. Know the 3 differences between web roles and web application projects. The 3 differences are:
6. In general, WCF works correctly on Windows Azure. There is a problem using "add service reference" or svcutil but we have a patch to workaround the problem. The patch is installed in the cloud, and more information about this is here: http://code.msdn.microsoft.com/wcfazure/Wiki/View.aspx?title=KnownIssues (not that a web.config change is also required)
7. Use the tools to configure the UI. Click on a role under the “Roles” node in Solution Explorer and select “Properties”.
This will bring up a UI over the Service Definition and Service Configuration file sections for that selected Role:
8. Each role instance is run in a process, all role process are attached to the debugger
When debugging, Visual Studio will attach to all of those processes as well as your web browser to enable debugging across roles and across instances.
You can correlate the role instance you are debugging to the instance in the development fabric by looking at the log messages and matching the PID. You can also right click and attach to the debugger from the development fabric and the subsequent dialog also shows the PID.
These processes in the Cloud will be 64-bit processes running on 64 bit Windows. Keep that in mind especially if you are calling native methods through pinvoke.
9. Project settings for debugging in role projects are read when running on the development fabric – Although we don’t read all of the values, we do pay attention to the project properties debuggers settings. For example on a web application project | project properties | Web tab, you can configure whether you want to to Native Code debugging, or Silverlight debugging.
10. Add multiple cloud service projects to the solution - you can use different cloud service projects to manage different configuration/definition files and different role configurations.
Tips for Migration
The NerdDinner sample code can be found at: http://nerddinner.codeplex.com/
10. Use an existing web application project as a web role
Right click on the Roles node in the Cloud Service project and select Add | Web Role Project in Solution…
The select the project you just added.
Then refer to tip #5 above (know the differences between an ASP.NET Web App project and a Web Role project) and selectively add references, trace listener and startup code as desired.
11. ASP.NET Provider scripts for SQL Azure
To use the ASP.NET providers with SQL Azure, you can use these scripts: http://support.microsoft.com/default.aspx/kb/2006191 to setup the database.
12. Know what Visual Studio tools work with SQL Azure.
Use SQL Server Management Studio 2008 R2 CTP3 (November) to connect to SQL Azure. (SSMS 2005 is not compatible and SSMS 2008 only support SQL Azure from the Query window)
Tips for Deployment
13. Test your app on the local development fabric with cloud storage. There are two reasons to do this:
14. Crack the Service Package using the _CSPACK_FORCE_NOENCRYPT_ environment variable. See this post for more information.
15. Use the Service Management APIs and Powershell cmdlets to automate deployment. See this post for more information.
The script I used to deploy the service was:
$cert = Get-Item cert:\CurrentUser\My\<enter cert> $sub = "<enter subscription ID>" $servicename = <enter service name>' $package = "<enter url to service package in blob storage>" $config = "<enter path to service configuration file>" Add-PSSnapin AzureManagementToolsSnapIn Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub | New-Deployment Staging $package $config -Label 'PDC09Staging' | Get-OperationStatus –WaitToComplete Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub | Get-Deployment -Slot Staging | Set-DeploymentStatus 'Running' | Get-OperationStatus -WaitToComplete
$cert = Get-Item cert:\CurrentUser\My\<enter cert> $sub = "<enter subscription ID>" $servicename = <enter service name>' $package = "<enter url to service package in blob storage>" $config = "<enter path to service configuration file>"
Add-PSSnapin AzureManagementToolsSnapIn
Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub | New-Deployment Staging $package $config -Label 'PDC09Staging' | Get-OperationStatus –WaitToComplete
Get-HostedService $servicename -Certificate $cert -SubscriptionId $sub | Get-Deployment -Slot Staging | Set-DeploymentStatus 'Running' | Get-OperationStatus -WaitToComplete
csmanage (tool that exercises the Service Management APIs) and other samples that aren't included in the Windows Azure SDK can be found here: http://code.msdn.microsoft.com/windowsazuresamples
Original Post: Tips and Tricks for Using Visual Studio 2010 to Build Applications that Run on Windows Azure
The content of the postings is owned by the respective author. AzureFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on AzureFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.