The easiest way to create business applications for the Desktop and the Cloud
UPDATED 8/29/2012: Updated for Visual Studio 2012 and Azure SDK 1.7.1
With the release of Visual Studio 2012, we’ve improved the experience for publishing LightSwitch applications to Windows Azure. The Azure deployment support for LightSwitch in Visual Studio 2012 depends on the Windows Azure SDK for .NET - June 2012 SP1, which was released August 15th. For more information on the release, please visit Jason and Scott’s blogs.
In V1 of LightSwitch we made publishing LightSwitch applications to Azure possible – in Visual Studio 2012 we’ve made it easy. If you’ve ever published a LightSwitch application to Azure you know it involves marshaling GUIDs and certificates between the Azure portal and the LightSwitch development environment in what could be best described as a “Version 1.0 Experience”. But this post is not about V1 of LightSwitch, so I won’t go into details there and will move right into what’s new in this release.
To start, the LightSwitch application you create doesn’t need to know anything about Azure until it’s time to publish. You can develop and test your application in the development environment and even publish to IIS before you make the decision to publish to Azure. When you’re ready to move to the cloud you simply sign up for your account and make the choice during publishing.
IMPORTANT: The latest release of the Azure SDK contains improvements to LightSwitch’s publish wizard making it even easier to publish to Azure Web Sites. Now more than ever, you may want to sign-up for this option as it is the perfect choice for many LightSwitch applications.
The first thing you will notice in Visual Studio 2012 is that the publishing functionality for Azure will first require downloading and installing the necessary components for Azure publishing. Doing so enables LightSwitch to always provide the latest features as Windows Azure evolves.
So, the first thing to do is download and install the Azure SDK. When you select Windows Azure as your publishing target, LightSwitch will walk you through the installation of the WPI feed that contains the Visual Studio components required to publish to Azure. Simply install the feed, restart Visual Studio and the new functionality is available.
If you already have the latest version of the Web Platform Installer you’ll be directed right to the SDK to install. If not, then you will be prompted to install the latest version of WPI before installing the Windows Azure SDK for .NET.
If you want to manually install the Windows Azure SDK for .NET then just select it in the Spotlight section or search for it in WPI. If you go the manual route, be sure to select the SDK feed for Visual Studio 2012. If you go the automatic route, it will be chosen for you.
Once installed, just go back to VS and you’re ready to go.
The first improvement we’ve made is to enable downloading and importing settings for managing your Azure subscriptions – this removes the need to copy/paste information between the Azure portal and VS. It also keeps the experience in-line with cloud publishing throughout Visual Studio. The settings you use to manage your Azure subscriptions are available to LightSwitch and Azure cloud projects alike.
If you don’t see your settings listed, simply 1) click the link to sign-in to Azure and download your settings and then 2) import those settings into the publish wizard.
NOTE: the file contains your subscription information as well as a management certificate that will allow VS to manage your account. Be sure to secure this file or delete it after you import it.
Once imported, these settings are saved, encrypted, in your profile. Other users in VS cannot see or use these credentials. In a shared development environment you may want to share the settings file with other users or have them create their own by following the steps above.
Once your Azure credentials have been chosen, the next step is to choose the service type. This is a new addition to the publish wizard, and gives you the choice to publish to an Azure Web Site or to a Cloud Service.
This article is organized to to cover the choice you make here in the following way:
If you chose the first option, publish to an Azure Web Site, then you need to make sure you have one provisioned first. Azure Web Sites are the perfect pairing for hosting a LightSwitch application in the cloud. Creating a site and a database couldn’t be easier in the new portal and you have all the benefits of the Windows Azure platform. Web sites are a good choice for getting a LightSwitch application to the cloud quickly and easily. Use this type of deployment when you don’t need the advanced features of a cloud service web role, like remote desktop, intellitrace, etc. Web sites are to Azure, what LightSwitch is to Visual Studio.
So, if you haven’t done so yet, you will need to provision a web site, . To begin the process, click the link Learn more about Windows Azure Web Sites on the publish wizard.
You can sign-up or add it to your existing Azure account. Once you’ve signed up, the only thing you need to do is create the web site. Typically, you will want to provision a database with your web site.
Using the new Windows Azure portal, the first step is to create the site along with a database. You can use an existing database if you like and even link that database to the new web site. Linking the site and database will put everything you need into a single publish profile that you can download and import into LightSwitch.
When creating or selecting a database you must be sure to open the firewall on your database to let LightSwitch publish to that database remotely. By default, your Azure database will not allow for remote management except by Windows Azure. The simplest way to allow remote management of your database from your IP address is to click “manage” within the Azure portal from the computer that will publish to the web site. Windows Azure will ask you if you want to enable management of the database from your current IP.
So now that you have provisioned an Azure Web Site, return to the publish wizard and select the option to publish to an Azure Web Site.
Having chosen to publish to a web site, you must now choose which web site to host your LightSwitch application.
This can be the web site you just created in the previous step, or one that already existed. If you just created one, make sure to click the “Refresh” button to populate the drop down with the newly provisioned site.
The next steps in the wizard are to configure the security and database settings. Since you are publishing to Azure Web Sites, you can skip over “Publish to an Azure Cloud Service” and jump down to the section called Securing your application.
To publish to an Azure Cloud Service, select the “Cloud Service” radio button.
Selecting this option allows you to publish to an Azure Cloud Service just as you have done in the past.
Once you make the decision to publish to a cloud service, you’ll be asked to select the cloud service that will host your application.
If you don’t want to publish to one of your existing services in the list, you can create a new one from the wizard without having to go to the portal. Select the environment, staging or production and you can continue to the next step. Or… you can change other settings to further customize your deployment.
If you want to enable remote desktop on your deployed application, simply check the box and provide a username and password for the remote desktop user. You can also specify a certificate and an expiration date if needed.
Advanced configuration options are optional settings you may use as the number of your Azure deployments grows. You can customize the name of the deployment to distinguish it from others and even include a time stamp automatically each time the application is deployed.
You can also select a storage account used and, as with other Azure artifacts, create a new one if needed.
Note: if you create a new service or storage account, be sure to collocate them as appropriate. For example, if your service is hosted in the East US region, you should use a storage account also hosted in the East Region as well.
The final option is to use an “upgrade” deployment method. Instead of provisioning the role from scratch, this option will simply update a LightSwitch application that’s already in place. This greatly reduces the time to availability of the service, but of course, this is only appropriate for upgrading applications because there is nothing to upgrade on a new application.
Now on to the next step, securing your application.
The next step in the wizard allows you to secure your application in the cloud. If your application uses authentication (strongly recommended) you need to specify the username of your application’s administrator.
The next step is to configure your HTTPS settings for your publish. How you configure this option will depend on the service type you chose earlier (web site or cloud service).
If you selected to publish to an Azure Web Site, then you will be given the option to choose whether HTTPS is required for your application. It is recommended that you use HTTPS for your LightSwitch applications as the data sent back and forth will not be encrypted otherwise.
If you choose HTTPS here, then you must configure your web site to require a secure connection.
If you chose to publish to a cloud service, the next step is to specify a certificate to use to secure your application over HTTPS. If you already have a certificate you can upload it to Windows Azure from the wizard, or if you don’t have one you can have the wizard create a temporary certificate for you, useful for staging environments.
The final step in securing your application is to specify a certificate to sign your application – so that when updates to your application are published, your users know the updates are from you. This step is optional in case you want to wait until you’re ready to roll out your application.
The final step in the publishing process is to specify the database or databases used by your application. By default you only need to specify your intrinsic database, if your application uses external data sources, you’ll have the option to change those here as well.
Another new option, though not unique to Azure publishing, is the option to not deploy the database. If you haven’t made changes to the database and want to leave your data intact, then you can skip the database publishing step by unchecking the box below. Note, however, if you have made changes to your database and “forget” this step, your application will deploy, but not run. If you’re unsure, just leave the box checked and LightSwitch will take care of necessary changes.
The last page in the wizard lets you review your information to let you do one last check before publishing. Also, the next time you come to the publish wizard you’ll jump straight to this page since all of your information is saved along with your project for future use.
Once you publish, you’ll see LightSwitch working for a while to build and publish your application, but you can go back to work once the publish is complete. If this is the first time you’ve published the application (or are not doing an upgrade) then Azure will continue to provision your role and application after LightSwitch has finished. You can monitor that progress in the portal and access your application once finished.
As you can see we made a lot of enhancements to the Azure publishing experience in LightSwitch so it is much easier to get your LightSwitch apps deployed to the cloud. Let us know what you think by adding a comment below. If you run into issues please post a question in the LightSwitch Forum – the team is there to help.
Brian Moore & Andrew Lader, LightSwitch Team
Thanks for detailed step-by-step guide!
I love this
Great article - but you used to be able to control whether you could access the site via HTTP or HTTPS previously. It appears as though that has gone from the development tools? If I wanted to do this in the future how is this achieved?
@SteveHiggon - The HTTPS settings have been moved to the publishing wizard's "Security settings" section. For more information on what's new in deployment as of RC see: blogs.msdn.com/.../lightswitch-iis-deployment-enhancements-in-visual-studio-11.aspx
LS looks great, as if someone at MS remembered the idea of user productivity. But Azure is driving me nuts. I'd like to try and host a LS app that uses MYSQL data; works from my desk, but frankly the Azure stuff looks far too messy and unlikely to work as I look at the publishing choices. Can someone tell me that Azure will host a LS app that uses off site data ? If I know this I'll plod on with Azure. (I'm using LS 2011)
I just installed the sdk (I'm using VS Pro 2012 on a win 7 machine), but when I try to publish I get an error "the following exception was thrown trying to publish: object reference not set to an instance of an object". I've rolled back the sdk and reinstalled, as well as re-installing the lightswitch module in VS: any other ideas?
Thanks for the guide!
Great guide, do you have any idea why we're getting this error after doing changes and trying to deploy? social.msdn.microsoft.com/.../6dd861fa-3ebc-471e-8720-1cb98eb298d3
I have a problem at the Database connections section.
I didn't see the option to create my Azure web site"with database" just the "Quick Create" option, so that's what I did.
When I got to the "Data Connections" step, I clicked the link "Provision a database at the Azure Portal" and privisioned a database.
I now see two empty text boxes "Specify the user connection" and "Publish Database Schema".
(1) I select the "..." button to the right of "Data Connections", (2) select my computer name as the server, (3) Select Windows Authentication, (4) I try "Select or enter a database name" but the databases I see are not for my app, (5) so I select attach and browse searching for *.mdf in explorer, (6) I see a file named "ApplicationDatabase.mdf" in my project folder so I assumed that must be the database, (7) I test the connection and get an error message saying it cannot be opened because it's version 706. This server supports 662 or earlier.
So at that point I am stumped. Please advise.
I have a subscription linked to my windows live id.
How can I Share my subscription/account so that an administrator/contributor/some other user with his own Live PUBLISH to my website.
I dont want to share my credentials. I want to delegate them access enough to publish to my website.
@sangeet - you can download a publishSettings file and give it to someone and they can publish to a specific website. That way they don’t need your Azure creds or even need an Azure account. You can find a link on the dashboard page of the Azure website called "Download Publish Settings". Then just import the settings file into the Publish Wizard above.
I have the Windows Azure SDK for .Net installed. Using the Wizard when I Select Enable Windows Azure Publishing I STILL get the prompt that the Windows Azure SDK for .Net must be installed to enable publishing to Windows Azure.
I have tried this is Visual Studio 2012 and 2013. I have tried uninstalling and reinstalling Azure. What needs to be done to Publish?
Its cold :)