Partager via


Mix ‘10: Building and Deploying Windows Azure-Based Applications with Microsoft Visual Studio 2010

Thank you to all of you who attended my session at Mix ‘10 on Building and Deploying Windows Azure-Based Applications with Microsoft Visual Studio 2010.  The video will be available within the next couple of days.

Here are some of the key takeaways and links from the session:

Getting Started

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.

Get the patches - https://msdn.microsoft.com/en-us/azure/cc974146.aspx

Samples

https://code.msdn.microsoft.com/windowsazuresamples

Using WCF on Windows Azure

https://code.msdn.microsoft.com/wcfazure

ASP.NET Web Roles vs ASP.NET Web Applications

The 3 differences are:

  • References to the Windows Azure specific assemblies: Microsoft.WindowsAzure.Diagnostics, Microsoft.WindowsAzure.ServiceRuntime, and Microsoft.WindowsAzure.StorageClient
  • Bootstrap code in the WebRole.cs/vb file that starts the DiagnosticMonitor as well as defines a default behavior of recycling the role when a configuration setting change occurs.
  • The addition of a trace listener in the web.config file: Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener.

NerdDinner

The NerdDinner sample code can be found at: https://nerddinner.codeplex.com/

ASP.NET Provider scripts for SQL Azure

To use the ASP.NET providers with SQL Azure, you can use these scripts: https://support.microsoft.com/default.aspx/kb/2006191 to setup the database.

Unzipping the Service Package

To be able to unzip the Service Package the environment variable you need is _CSPACK_FORCE_NOENCRYPT_. See this post for more information.

Run you app on the devfabric with cloud storage before deploying to Windows Azure

Do this to weed out potential problems with connection strings including deploying with a connection string pointing to the development storage.

Right click on the Cloud Service project and select Properties:

image

Select the “Development” tab and change “Start Development Storage services” to “False”.

image

Shut down the development storage service:

image

Change your connection strings.  Do this for every role.  Right click on the role under the Roles node in Solution Explorer and select Properties.

image 

Switch to the “Settings” tab and for each connection string, bring up the connection string dialog and enter your cloud storage credentials.

image

Run your Cloud Service on the Development Fabric and make sure that everything works as expected.

Service Management

Windows Azure has a the Service Management APIs and Powershell cmdlets you can use to automate deployment and service management.  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 or local file path>"
$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

If you pass in a local file for the $package variable, you must have a storage account with the same name as the hosted service account you are deploying to.

csmanage (tool that exercises the Service Management APIs) and other samples that aren't included in the Windows Azure SDK can be found here: https://code.msdn.microsoft.com/windowsazuresamples