Deploying Silverlight + Web Service + Database to the cloud

已答复 Deploying Silverlight + Web Service + Database to the cloud

  • Wednesday, April 04, 2012 2:25 PM
     
     

    Hi

    I want to migrate the folowing typical Silverlight-situaties to the cloud. I have 2 projects:

    • A web project, containing a Default.aspx-page for the Silverlight-applicatie, a web service, and a small database (MDF-file)
    • A silverlight project, using the web service

    I think it's a good idea to be able to run my application on Windows Azure (remote) and locally. But...

    • That means I have to create a "copy" of my MDF-database (in App_Data) on SQL Azure. It also means I don't need to "publish" my App_Data folder, since it won't be used online. On the other hand I need to update the SQL Azure copy (according to my MDF-file) everytime I deploy my application?
    • I need 2 connection strings, one for the online version (an SQL Azure connection string) and one for the local version (MDF). I read I can use my two cscfg-files for that purpose?
    • ServiceReferences.ClientConfig in my Silverlight contains the endpoint URI of my webservice. When I run my application locally, it's 127.0.0.1:81/..., but when I run my application in the cloud, it's cloudapp.net:80/... Can I save the endpoint configuration in cscfg-files?
    • I want to be able to use the option "Update Service Reference". Unfortunately, when my solution is not running, retrieving the necessary information from the webserver is impossible, and when my solution is running, the option to update my service reference is grayed out.

    Any suggestions?

    Thanks!

All Replies

  • Thursday, April 05, 2012 6:09 AM
     
     Answered

    Hi Afritmans,

    Here are my suggestions:

    • You shouldn't have a database (like the MDF db) on your instances. This does not scale and your data isn't persisted (it might disappear during a reimaging, hardware failure, ...). Like you said, SQL Azure is the way to go. But it's true that you'll need to update the database each time you deploy the application. A common practice is to create 1 SQL script per change, and include a timestamp or a sequence number in the filename. That way, when you're upgrading the database, you can just 'replay' the scripts in order.
    • If you work with different environments (local, test, acceptance, production, ...) it's a good idea, like you said, to have to have multiple cscfg files. You can manage these by choosing manage under Service Configuration  
        

        
    • Yes you can save your endpoint configuration in the cscfg files. But, you'll need to be able to pass that information (server-side) to your Silverlight client (client-side). This can be done by adding some javascript to your page for example, where you'll send the URI to Silverlight. Once you have the URI in Silverlight, you'll need to pass it to the service client.
    • For the update service reference part this is normal. If you're not running, Visual Studio can't access the MEX endpoint. If you are running, you are in debug mode and you can't modify the projects. What you should try is right click on your cloud project, choose Debug and choose Start without Debugging. This way your MEX endpoint is available and you'll be able  to update the service reference.

    Hope this helps.

    Sandrino


    Sandrino Di Mattia | Twitter: http://twitter.com/sandrinodm | Azure Blog: http://fabriccontroller.net/blog | Blog: http://sandrinodimattia.net/blog