MOBILE

Windows Phone 7 Development : Building a Phone Client to Access a Cloud Service (part 5) - Deploying the Service to Windows Azure

1/18/2011 3:57:18 PM
8. Deploying the Service to Windows Azure

By deploying to Windows Azure, you will have a redundant, fault-tolerant service that you can scale out if you need to meet the demands of heavy usage. You will learn how simple it is to configure the service and deploy.

8.1. Preparing for Windows Azure NotepadService

You will be creating a Windows Azure service host in order to deploy WCF NotepadService to a Windows Azure platform.

8.1.1. Signing Up for Windows Azure and Creating a Project
  1. Open the browser of your choice.

  2. Go to www.microsoft.com/windowsazure/ to sign up and buy the Windows Azure service account. Follow the directions provided by Microsoft in order to purchase and acquire the service account in order to continue with the following steps.

  3. Go to https://windows.azure.com/ and sign in using the account you created in Step 1.

8.1.2. Connecting to the Windows Azure Project
  1. Once you've signed in, click the Windows Azure menu tab on the left side. When the Windows Azure page loads, you will see the project that you created during the registration process (see Step 1). See Figure 10, which will correspond to this step.

    Figure 10. Windows Azure project list
  2. Click the project hyperlink NAS-DEV. In your case, you should click the name of the project that corresponds to the one you created in Step 1.

8.1.3. Creating Windows Azure NotepadService
  1. When the page loads, if you previously created services, you will see the list of the services, as shown in Figure 11. Let's create a new service that will host your WCF service by clicking the "+ New Service" link on the left side of the page.

    Figure 11. Adding a new Azure service to the project

When the next page loads, you will be given an option to choose either "Storage Account" or "Hosted Services." Choose "Hosted Services." See Figure 12 for the options you will see displayed.

Figure 12. Choosing Hosted Services

  1. When the Service Properties dialogue shown in Figure 13 displays, enter "NotepadService" as the Service Label and "This is the WCF service for the Windows Phone 7 Notepad demo application," as the Service Description. Now click the Next button to display the Hosted Service Dialogue on the page.

    Figure 13. Creating Azure service
8.1.4. Configuring Windows Azure NotepadService

Now you're ready to configure the service that you created in the previous section.

  1. When the Hosted Service dialogue displays, enter "NotepadService" as the Public Service Name of the Public Hosted Service URL name. Click the Check Availability button to make sure the service name is not taken by someone else.

  2. In the Hosted Service Affinity Group section of the Hosted Service dialogue, you have two options to choose from. Typically, relating the affinity among other services allows you to run the services in the same region in order to optimize performance.

    1. If you are creating multiple services that will interact with other services in the same region, then you will want to choose "Yes" and choose the existing Affinity Group from the drop-down.

    2. If you create a new Affinity, you can associate to this affinity when you are creating other services. Choose "No" as you will not be creating multiple services that will require the services to be in the same region, and then select the "Anywhere in US" option from the drop-down.

    See Figure 14 for appropriately filled information. Notice here that for the region you would want to choose the region that you are close to for optimal performance. If you are planning to deploy the application targeting a specific region, then you would want to make sure to choose the appropriate region here.

    Figure 14. Configuring the Azure service
  3. Click the Create button and you will see Figure 15. Now you are ready to deploy the WCF application that you created in the foregoing section. Notice here that you will be able to deploy first to staging to test your WCF and then deploy to production. This is a very nice feature in that you will be able to test the application running against a real cloud-based service without first deploying to production.

    Figure 15. NotepadService main screen

Keep this browser open as you will be coming back and deploying the packages.

8.2. Deploying NotepadService to Windows Azure

In the foregoing steps, you prepared the NotepadService host, and now it is time for you to deploy NotepadService so that you can consume the Azure service from the phone. We will be deploying the service to staging first. Staging is where you test your service before going to production. This is a very convenient way of making sure your service works before deciding to go live.

8.2.1. Compiling and Publishing NotepadService

We will need a compiled binary so we can deploy to the Windows Azure host.

  1. Go to your NotepadService project, stop the project if it is running, right-click the NotepadService project, and choose Publish.

  2. The Publish Cloud Service window will appear. Choose Create Service Package Only, as shown in Figure 16.

    Figure 16. Create a NotepadService package for Windows Azure
  3. Click the OK button and you will notice that Windows Explorer will open with a directory where you will see two files: NotepadService.cspkg is the compiled binary of NotepadService and ServiceConfiguration.cscfg is the configuration file used by Windows Azure. Take note of the directory path as you will be uploading these files to Windows Azure.

8.2.2. Deploying NotepadService.cspkg and ServiceConfiguration.cscfg to Windows Azure

You will be deploying the packages created in the previous steps to Windows Azure.

  1. Go to your browser where the NotepadService host main screen is, as shown in Figure 17.

  2. Click the "Staging Deploy..." button.

  3. In the Application Package section, click the Browse button and select NotepadService.cspkg. In Configuration Settings, click Browse to select ServiceConfiguration.cscfg, and choose Automatic for Select OS Upgrades. It is best to have Azure upgrade the OS automatically because each upgrade will include security patches and framework updates. In "Choose a label for this deployment," put "Version 1.0.0". It is best to label the service you are deploying using the version scheme to overcome any future confusion of what is deployed to the Azure service. You should see a screen that resembles Figure 17.

    Figure 17. Staging Deployment screen
  4. Click Deploy. The main screen page will be loaded, as shown in Figure 18.

    Figure 18. NotepadService main screen after packages are uploaded
  5. Click Run to run NotepadService. This step will take a while, as long as five minutes. When the service is ready, you will see the Ready status. Notice here that there is a temporary web site URL, which now you can use in your Notepad phone application.

9. Testing the Notepad Application Against NotepadService Azure Service

In the foregoing steps, you deployed NotepadService to the Windows Azure host. You will be changing the Notepad phone configuration to point to the web service that is hosted in Windows Azure and test in the same way you tested against when the service was deployed locally to your machine.

  1. Go to Visual Studio with the Notepad project.

  2. In Solution Explorer under the Notepad project, open ServiceReferences.ClientConfig. Change the endpoint address from 127.0.0.1:81 to the URL that you received when you deployed to staging in previous steps. See Figure 19 with the changed endpoint address.

    Figure 19. Changing the service endpoint to the Windows Azure address
  3. Make sure that NotepadService is in Ready status, and then press F5 to run your Notepad phone application in the emulator. Follow the previous steps to test the Notepad application—it should exhibit exactly the same behavior, except that now you are running your Notepad application against the Windows Azure service.

Other  
  •  Windows Phone 7 Development : Building a Phone Client to Access a Cloud Service (part 4) - Coding NotepadViewModel
  •  Windows Phone 7 Development : Building a Phone Client to Access a Cloud Service (part 3) - Coding the BoolToVisibilityConvert
  •  Windows Phone 7 Development : Building a Phone Client to Access a Cloud Service (part 2) - Coding MainPage
  •  Windows Phone 7 Development : Building a Phone Client to Access a Cloud Service (part 1) - Building the User Interface
  •  Building Android Apps : Detecting Browsers with WURFL
  •  Building Android Apps : Submitting Your App to the Android Market - Preparing a Release Version of Your App
  •  Windows Phone 7 Development : Creating a Cloud Service to Access the Cloud Database (part 2) - Implementing a WCF Service to Access the SQL Azure Database
  •  Windows Phone 7 Development : Creating a Cloud Service to Access the Cloud Database (part 1) - Generating an Object Model to Access the Cloud Database
  •  Windows Phone 7 Development : Using Cloud Services As Data Stores - Creating a Cloud Database
  •  iPhone Application Development : Working with Text, Keyboards, and Buttons (part 5) - Implementing the View Controller Logic
  •  iPhone Application Development : Working with Text, Keyboards, and Buttons (part 4) - Hiding the Keyboard
  •  iPhone Application Development : Working with Text, Keyboards, and Buttons (part 3) - Creating Styled Buttons
  •  iPhone Application Development : Working with Text, Keyboards, and Buttons (part 2) - Adding Text Views
  •  iPhone Application Development : Working with Text, Keyboards, and Buttons (part 1) - Adding Text Fields
  •  Building Android Apps : Controlling the Phone with JavaScript (part 3) - Accelerometer
  •  Building Android Apps : Controlling the Phone with JavaScript (part 2) - Geolocation
  •  Building Android Apps : Controlling the Phone with JavaScript (part 1) - Beep, Vibrate, and Alert
  •  Building Your First Windows Phone 7 Application (part 5) - Styling Your Application
  •  Building Your First Windows Phone 7 Application (part 4) - Customizing Your First Windows Phone Application
  •  Building Your First Windows Phone 7 Application (part 3) - Writing Your First Windows Phone Code
  •  
    Top 10
    Windows Phone 7 : Working with Controls and Themes - Panorama and Pivot Controls
    Windows Phone 7 Development : Working with Video (part 1)
    Windows Phone 7 Development : Wiring Up Events to an Application Bar ( part 2)
    Programming Microsoft SQL Server 2005 : Querying XML Data Using XQuery (part 2) - SQL Server 2005 XQuery in Action
    Wireless Security in Windows Vista
    Sharing Files and Folders Over the Network in Vista
    SQL Server 2008: Managing Resources with the Resource Governor (part 2) - Workload Groups
    Mobile Application Security : SMS Security - Overview of Short Message Service
    Filtering Out Evil with Firewalls (part 1)
    Windows 7 : Detecting and Resolving Computer Problems (part 2) - Tracking Errors in the Event Logs
    Most View
    Visual Studio 2010 : Understanding Solutions and Projects (part 3)
    Mobile Application Security : BlackBerry Security - Introduction to Platform
    SQL Server 2008 : Auditing SQL Server - Creating SQL Server Audits with T-SQL
    Active Directory Federation Services (ADFS)
    Programming .NET Security : Programming Cryptographic Keys (part 2) - Using Key Persistence
    Configuring Server Roles in Windows 2008 : New Roles in 2008
    SQL Server 2008 : Performance Tuning - Tracing with SQL Profiler
    Establishing Mobile Connections in Vista
    SQL Server 2008 : Programming Objects - Implementing Functions
    SharePoint 2007 : Publish a File or List Item
    Exchange Server 2010 : Developments in High Availability (part 2) : Configuring a Database Availability Group & Managing database copies
    Windows 7 : Using Windows Defender (part 3) - Using Windows Defender Tools & Troubleshooting Windows Defender
    SQL Server 2008 : Roles
    Understanding Windows 7 Personalization
    Upgrading to Windows Server 2003 : Planning a Windows NT Domain Upgrade (part 3) - Making a Recovery Plan
    Programming .NET Security : Asymmetric Encryption Explained (part 2) - Creating the Encrypted Data
    Parallel Programming : Introducing Parallel Computing
    Windows Server 2008 : Securing Internet Information Services 7.5
    Windows 7 : Understanding TCP/IP (part 1) - Basics of IP Addressing and Configuration
    Upgrading to Windows Server 2003 : Planning a Windows NT Domain Upgrade (part 2) - Planning the Active Directory Forest