none
WP7 + WCF + AzureStorage

    Question

  • Hi there,

     

    I have a wp7 application which wants to upload data in the cloud, putting the text data in sql azure and image data in azure storage. I have a cloud project which has a WCF web role to enable the phone to access sql azure by calling wcf service. Now I want to realize the function of uploading images to azure storage via wcf service. According to some information online, I modified my cloud project. However, when I run the wcf web role as start project, it will throw SEHException when I try to upload image. It is said to be caused by role environment not ready and can be fixed by running the cloud project as the start project. However, when I ran with the cloud project as start project, it will throw no endpoint listening exception when I try to access sql azure, since obviously the wcf service is not up (the localhost service web page doesn't show up). How can I make them two work at the same time? Or is there anything wrong? How can I fix it? 

    Any suggestion will be highly appreciated! Thank you very much!

    Tuesday, April 12, 2011 6:28 AM

Answers

  • Hi lulu

    have you tried to make the cloud project your start project?  I assume if you start your solution this way, the RoleEnvironment will be there.

    Edit: Yes you did. You wrote:

    "it will throw no endpoint listening exception when I try to access sql azure, since obviously the wcf service is not up (the localhost service web page doesn't show up)"

    So from my perspective you need to solve this issue to make it run. May you give me some more details?

    Edit 2: I suggest you try this sample http://msdn.microsoft.com/en-us/library/gg651130.aspx and compare it with your current solution.

    Wednesday, April 13, 2011 7:57 AM

All replies

  • Hi lulu

    as far as I remember this exeption is seen if something goes wrong with the configuration setting and the RoleEnvironment is not available. Please check these lines:

    string connectionString = RoleEnvironment.GetConfigurationSettingValue("DataConnectionString");
    CloudStorageAccount account = CloudStorageAccount.Parse(connectionString);
    

    As well if you run azure sdk 1.3, you should make sure that the web.config file of the asp.net project is not read-only (source control).

     

    Tuesday, April 12, 2011 6:47 AM
  • Hi Marc,

     

    Thank you for your immediate reply! Yes, it is the connectionString line going wrong and the RoleEnvironment is not available. But how can I make the RoleEnvironment available? I saw some posts online saying that this problem would go away if you run the cloud project with the cloud project as the start project. Currently I'm running the cloud project with the wcf web role as the start project, and when I run it the azure storage emulator will not be launched but there will be localhosted wcf service web page coming out. So I changed it and make the cloud project as the start project. This time when I run it the azure storage emulator will come out however the service web page doesn't show and I cannot call the wcf service which access sql azure. So how can I make the whole cloud project running at the same time?

    Thank you very much

    Wednesday, April 13, 2011 2:10 AM
  • Hi lulu

    have you tried to make the cloud project your start project?  I assume if you start your solution this way, the RoleEnvironment will be there.

    Edit: Yes you did. You wrote:

    "it will throw no endpoint listening exception when I try to access sql azure, since obviously the wcf service is not up (the localhost service web page doesn't show up)"

    So from my perspective you need to solve this issue to make it run. May you give me some more details?

    Edit 2: I suggest you try this sample http://msdn.microsoft.com/en-us/library/gg651130.aspx and compare it with your current solution.

    Wednesday, April 13, 2011 7:57 AM
  • Hi Marc,

    Thanks for your suggested tutorial. It turns out to be a stupid error which resulted from my lack of understanding of how the cloud project works. When I run the webrole as start project, the service address is different from the one when I run the cloud project as start project. I don't know this so in my client code the end point is still the old address. No wonder it reports no endpoint.

    Here is another issue: After correcting the above error, I tried to upload images to azure storage. It reports no error when I hit the submit button and return success information ( In the submit method of the wcf service, it will upload the data to azure storage first, and then insert some data into sql azure, and return a success message when this function returns.) However, when I tried to view the image, no matter it's via the address of storage emulator or the address of the real azure storage, the webpage is always "cannot find page". Would you please give any suggestion that what might cause this problem?

    Thank you very much!

    Wednesday, April 13, 2011 9:50 AM
  • Hi Marc,

    Thank you for your help! I'm wondering whether there is anything I need to do when I deploy it to a real device? Currently, it works well on a phone emulator, no matter it's upload image to the storage emulator or real azure storage. However, when I deployed to a wp7, it doesn't work. Do I need to do anything before deployment to the phone?

     

    Thanks!

    Thursday, April 14, 2011 5:39 AM
  • Hi Lulu

    I suggest you open a new thread with this request for easier readability.

    Good luck!

    Marc

    Thursday, April 14, 2011 8:07 AM
  • Hi Marc,

    Sorry. I've opened a new thread.

    Thank you for your help!

    Lu

    Thursday, April 14, 2011 8:25 AM
  • Hi marc,

    I am facing a problem continuously that RoleEnvironment is unavailable in a WCF Cloud service. I have taken several measures (like making the Cloud Project as the Startup project and all) but nothing seems to be working. 

     

    Please suggest something

     

    Thanks

    Ajay

    Saturday, June 18, 2011 8:04 PM