This Toolkit is now deprecated and is now

superseded by Windows Azure Mobile Services

The Windows Azure Toolkit for Windows Phone provided developers with the first iteration of support for building backend services for Windows Phone apps using Windows Azure.  The main areas of feedback we received from mobile developers was that they wanted a turn-key set of services for common functionality such as notifications, auth, and data.   Windows Azure Mobile Services directly reflects this feedback by enabling developers to simply provision, configure, and consume scalable backend services. The downloads for this toolkit will be removed on the week of Feb 1st 2013 and all future improvements will be channeled into Windows Azure Mobile Services rather than this toolkit. 

To get started with Mobile Services, sign up for a Windows Azure account and receive 10 free Mobile Services.


WAT Windows Phone

This section provides a walkthrough for the CRUDSqlAzure sample application. This application was developed using the Windows Phone Cloud Application project template included in this toolkit.

 

Starting the application

After installing the toolkit and running the SetupSample.cmd setup script for this sample, perform the following steps to go through the CRUDSqlAzure application.

Note: If you face any problems while following these steps, please make sure to review the Troubleshooting section.

  1. Open Visual Studio 2010 as administrator (this is required to run Windows Azure projects).
  2. In the File menu, point to Open and then click Project/Solution.
  3. Browse to the Samples\WP7.1\CRUDSqlAzure folder, choose CRUDSqlAzure.sln and click Open.
  4. Explore the sample. You should see the following projects:
    • CRUDSqlAzure: Windows Azure project with a Web Role configured.
    • CRUDSqlAzure.Phone: Silverlight for Windows Phone project containing a sample application that shows how to perform CRUD operations against an OData service.
    • CRUDSqlAzure.Web: ASP.NET MVC 3 project configured as a Web Role containing the services consumed by the phone application and the administration pages.
      image
  5. Additionally, the solution includes the source code for the following libraries used:
    1. Microsoft.Samples.Data.Services.Client.dll: Modified version of the OData client library for Windows Phone (System.Data.Services.Client) to make it work with the Windows Azure Table Service API (http://odata.codeplex.com).
    2. MIcrosoft.Samples.DPE.OAuth.dll: Microsoft DPE OAuth2 library.
    3. SL.Phone.Federation.dll: Microsoft Silverlight ACS sign in control.
    4. WindowsPhoneCloud.StorageClient.dll: Windows Azure Storage Client library for Windows Phone.
  6. Make sure that you do not have any Web site running in ports 443 and 10080 on your local IIS.
    Note: By default, the ASP.NET MVC 3 Web Role is configured to run over two different endpoints: one HTTPS in port 443 and another HTTP in port 10080.
  7. Make sure that the target for Silverlight for Windows Phone projects is set to Windows Phone Emulator.
  8. In Solution Explorer, right-click the Windows Azure project, point to Debug and click Start new instance.
  9. Wait for the Web Role to start and click the Continue to this website (not recommended) link to be able to browse the site despite of the certificate warning. You will get a forbidden error because the Web site does not have any pages (it only hosts a WCF Service), and IIS by default does not allow anonymous users to list the site directory.
    image
  10. To log into the Web application use the following credentials:
    • User Name: admin
    • Password:image (with a zero)
  11. In Solution Explorer, right-click the Windows Phone project, point to Debug and click Start new instance. This will launch the Windows Phone Emulator and start the application.
  12. The application will redirect you to the log in page.
    image
  13. In the log in page, click the Install certificate link. This will open Internet Explorer in the Windows Phone Emulator at http://127.0.0.1:10080/127.0.0.1.cer.
    image
    Note:
    In order to consume the REST services over HTTPS in a Windows Phone device or in the Windows Phone Emulator, you need to use a trusted SSL certificate. If you do not have one, you can use a self-signed certificate, but you need to install it in the phone before consuming the services. Since the Computer Emulator always uses the 127.0.0.1 self-signed certificate, we need to install it in the Windows Phone Emulator before continuing with the next steps.
     
  14. Click the shield icon to install the Windows Azure Compute Emulator’s SSL certificate in the Windows Phone Emulator. Finally, click install to confirm that you want to install the certificate.
    image
    Important: If you leave the Windows Phone Emulator open, you do not need to install the certificate every time that you run the application. However, if you close the Windows Phone Emulator, you will have to install it again.
     
  15. Once the certificate is installed, click ok and navigate back to the running application using the left arrow (image).
    image

 

Authenticating The User

  1. Select the identity provider you want to authenticate with and log in providing your account information.
    image
  2. If this is the first time you logged into the application, you will be redirected to the register page. Enter a name and an email address for the user, and then click register. Wait for the registration to complete. If the registration was successful, you will see the Registration Successful message. Click ok and you will be redirected back to the log in page.
    image
    Note: The Windows Phone Emulator supports mapping of the keyboard on your development computer to the hardware keyboard on a Windows Phone (by default is not enabled). To enable the keyboard in the Windows Phone Emulator press the PAGE UP or PAUSE/BREAK key. To disable it, press the PAGE DOWN or PAUSE/BREAK key. For more information, see the following article: http://msdn.microsoft.com/library/ff754352(VS.92).aspx.

 

Working with all permissions

  1. After completing the log in page, you will be taken to the products page. You can browse all the products loaded in the database. Click in the Chai product to view its details.
    image
  2. In this page, you can see the detailed information of each record in the Products entity set.
  3. Change the Name to Chai (Tea) and click the save button (image). You will notice an error message saying that you do not have permissions to update products.
    image
  4. Go to the administration site and in the Users tab, choose SQL Update for the user John Doe and click Save.
    image
  5. Back in the phone application click the save button (image) again. This time, the changes will be saved and you will be taken to the Products page where you can see the new data for the product.
    image
  6. Now, choose the Chang item and in the details page select Discontinued, and click the save button (image). Once the product is discontinued, click the Chang item again and in the details page click the delete button (image).You will notice an error message saying that you do not have permissions to remove products.
    image
  7. Go to the administration site and in the Users tab, choose SQL Delete for the user John Doe and click Save.
    image
  8. Back in the phone application click the delete button (image) again. This time, the item will be deleted and you will be taken back to the products page, this time the product will be removed.
    image
  9. To add a product, click the plus button (image). Load the form with new sample data and click the save button (image). You will notice an error message saying that you do not have permissions to add products.
    image
  10. Go to the administration site and in the Users tab, choose SQL Create for the user John Doe and click Save.
    image
  11. Back in the phone emulator, click the save button (image) again. This time the product will be added and the application will navigate to the products page. To see the item you have just added, scroll to the bottom of the page, when you reach the end, click Load More…, repeat this action until you reach the end of the list.
    image
  12. Finally, go to the administration site and in the Users tab, choose SQL Read for the user John Doe and click Save.
    image
  13. Back in the phone emulator, click the refresh button and notice the error message saying that you do not have permissions to read the products entity set.
    image

 

Next step: Troubleshooting

Last edited Jan 21, 2013 at 9:25 PM by nharris, version 7

Comments

No comments yet.