One of the most common requests I’ve received for the Windows Azure Toolkit for Windows Phone 7 has been a tutorial for deploying the services to Windows Azure. It’s taken longer than it should have—my humblest apologies—but I’ve finally put one together. You’ll need to follow the following steps outlined below:
- Create a Certificate (used for SSL)
- Export the PFX File
- Upload the PFX File to Windows Azure
- (optional) Supporting Apple Push Notifications
- Update and Deploy to Windows Azure
- Update Your Windows Phone Project
If you have any problems or confusion regarding the steps below, please let me know.
Create a Certificate
- Open the Visual Studio Command Prompt window as an administrator.
- Change the directory to the location where you want to save the certificate file.
- Type the following command, making sure to replace <CertificateName> with your hosted service URL:
For example:Note: The makecert tool will both create the .cer file and register the certificate in your Personal Certificates store. For more information, check the following article: http://msdn.microsoft.com/en-us/library/gg432987.aspx.
Export the PFX File
- Open the Certificate Manager snap-in for the management console by typing certmgr.msc in the Start menu textbox.
- The new certificate was automatically added to the personal certificate store. Export the certificate by right-clicking it, pointing to All Tasks, and then clicking Export.
- On the Export Private Key page, make sure to select Yes, export the private key.
- Choose a name and export the file to a .pfx file.
- Finish the wizard.
Note: You now have a copy of the certificate (.pfx) with the private key. For more information, check the following article: http://msdn.microsoft.com/en-us/library/gg432987.aspx.
Upload the PFX File to Windows Azure
- Open a browser, navigate to the Windows Azure Platform Management Portal at https://windows.azure.com and log in with your credentials.
- Select Hosted Services, Storage Accounts & CDN and then Hosted Services.
- Expand your hosted service project, and select the Certificates folder.
- Click Add Certificate.
- Click Browse and select the PFX file you saved. Enter the password, and click Create.
- Once the certificate has been uploaded and created, copy the Thumbprint for later use.
Supporting Apple Push Notifications
During the project creation through the project template, you are given the option to support Apple Push Notifications through the Azure Web role.
If you chose to support Apple Push Notifications, please follow these additional steps:
- In order to use the toolkit to send Apple push notifications, you should have obtained the appropriate SSL certificate for your iOS application. You can find more information on how to obtain an Apple development certificate in the Provisioning and Development article in the Local and Push Notification Programming Guide.
- Upload the same Apple development certificate selected during the project template wizard to your hosted service. To do this, you can follow the same steps required to upload the SSL certificate described in the previous section.
Update and Deploy to Windows Azure
- In the Windows Azure Project, double-click the role (e.g. WP7CloudApp1.Web) to open the role properties.
- Select the Settings tab and update the DataConnectionString and Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString to point to your production storage account.
- Select the Certificates tab, and set the SslCertificate property value to the Thumbprint you saved from the Windows Azure portal. This will replace the thumbprint for the localhost certificate with the thumbprint related to the certificate you uploaded into your hosted service.
- Add the .cer file to your web application project. This way, you can point your phone users to download the certificate and install into the emulator. Right-click on the Web application project, choose Add Existing Item, select the .cer file you previously created, and add it to the project.
- Open the .cer file properties and make sure that the Build Action is set to Content.
- Now you can publish your Windows Azure project to your hosted service. You can do this from the Windows Azure Platform Management Portal or directly from Visual Studio 2010.
Update Your Windows Phone Project to Consume Your Windows Azure Hosted Service
- In your Windows Phone project, open the App.xaml file.
- Update the following resources:
KeyValueSSLCertificateUrlhttp://<YourDNSPrefix>.cloudapp.net:10080/<CertificateName>.cerSharedAccessSignatureServiceEndpointhttps:// <YourDNSPrefix>.cloudapp.net/SharedAccessSignatureServiceAzureStorageTableProxyEndpointhttps:// <YourDNSPrefix>.cloudapp.net/AzureTablesProxy.axdAzureStorageQueueProxyEndpointhttps:// <YourDNSPrefix>.cloudapp.net/AzureQueuesProxy.axdAuthenticationServiceEndpointhttps:// <YourDNSPrefix>.cloudapp.net/AuthenticationServicePushNotificationServiceEndpointhttps:// <YourDNSPrefix>.cloudapp.net/PushNotificationService
- To test against the deployed services, right-click the Windows Phone project, navigate to the Debug context menu, and click on Start new instance.
I hope this helps!