CHAPTER 18

image

Deploying Your Application

The last chapter of this book focuses on deployment. I’ll show you how to allow users to access your application, and you’ll finally get the chance to show off all the hard work that you’ve carried out on your LightSwitch project. With all the tips and tricks that you’ve learned, your users will surely be impressed. In this chapter, you’ll find out how to

  • Use the Publish Wizard to deploy both desktop and web applications
  • Set up and configure a web server
  • Publish your applications onto Windows Azure

There are many ways for you to deploy an application, and the method that you choose depends on your application type and infrastructure. This chapter explains all the possible options and shows you exactly how to carry out a deployment.

Getting Started with Deployment

LightSwitch allows you to create HTML Client or Silverlight applications that can run on either the desktop or web. It also relies on the application services that can run on a server, Azure, or the client workstation (in the case of a desktop application). This combination results in several distinct deployment scenarios, each with a unique set of installation tasks. Figure 18-1 highlights your choices in the form of a flow diagram and shows you the main tasks that you’d need to carry out. You can use this diagram to help you identify the sections in this chapter that you can skip over. For example, you can ignore the sections on setting up Internet Information Services (IIS) and ASP.NET if you want to deploy a desktop application and install your application services on the workstation.

9781430250715_Fig18-01.jpg

Figure 18-1. Deployment steps

The rest of this chapter is arranged as follows. I’ll begin by explaining some of the underlying principles of deployment, and then show you how the Publish Wizard works. If you’re publishing a web application, you’ll need to set up a web server before you run the Publish Wizard. The next part of this chapter shows you how to install IIS, and then shows you how to work with the output that’s generated by the Publish Wizard.

Choosing an Application Topology

LightSwitch relies on application services that can run in IIS, Windows Azure, or the end user’s machine. If you’re deploying a web application (either Silverlight or HTML client), your application services must be hosted in IIS or Windows Azure. But if you’re deploying a Silverlight desktop application, you can choose to host the application services on the local machine, and this is a configuration that’s called a “two-tier” setup. The advantage of running the services locally is that it’s easier to set up. Unlike a “three-tier” setup, you don’t need to go through the tricky process of setting up a web server, or understanding how Windows Azure works. But the disadvantage is that you’ll need to install the services on every machine that you want to run your application. Two-tier applications are therefore more suitable for single-user applications or applications that don’t have many users. In this type of deployment, you can also choose to install the database on the end-user machine by using a local instance of SQL Server or SQL Express. This means that you can run your entire application from a single machine.

Choosing Whether to Publish or Package

If you want to host your application services in IIS, you can choose to either publish or to package your application (Figure 18-2).

9781430250715_Fig18-02.jpg

Figure 18-2. Publishing vs. packaging

If you choose to publish your application, LightSwitch deploys it directly from Visual Studio onto your IIS server. It’s very easy to publish an application, but you’ll need to carry out more work to prepare your IIS server beforehand. The operating systems that support publishing are Windows Server 2003 or above, and Windows 7 or above.

The second option is to package your application. Packaging produces a set of install files that you would manually copy and install on your server. Packaging an application is easier than publishing. There are fewer tasks to carry out on your web server, and you don’t need to struggle to make Visual Studio talk to IIS. For example, your application will fail to publish if a firewall blocks the ports that are required for publishing to work (port 8172 by default). If you’re developing your application on a machine that isn’t on the same domain as the server that you want to deploy to, packaging is a good choice.

Setting Up Your Workstations

In order to set up a workstation to run LightSwitch, there are actually very few tasks for you to carry out. HTML client applications require only a web browser, so in almost all cases, you don’t need to carry out any additional work. Silverlight applications require the Silverlight 4 runtime. If a user doesn’t have the runtime installed and attempts to run a Silverlight browser application, the application displays a web page that prompts the user to download the Silverlight runtime from the Microsoft web site. If you’re in a corporate environment, you can distribute the Silverlight runtime by using group policy, SMS (Microsoft Systems Management Server), or some other software distribution mechanism. Some companies have policies in place that block Silverlight or Adobe Flash. If you have a policy like this in place, your Silverlight LightSwitch application will simply not work.

Setting Up SQL Server

In all deployment scenarios, you’ll need a database server with SQL Server 2005 or above to host your application. If you’re deploying your application into Windows Azure, you’d create a SQL Azure database rather than carry out an “on premises” installation of SQL Server. If you’re building a two-tier desktop application, you can install SQL Server Express on the client and run your entire application on the workstation. This type of setup is ideal for single-user or stand-alone applications. SQL Server Express is a free edition of SQL Server, and it’s perfect if you don’t have a license for a higher, paid-for edition of SQL. A disadvantage of SQL Server Express is that it limits performance by placing restrictions on the amount of memory and CPU cores that the database engine can use. You can find out more and download SQL Express from the following web site:

http://www.microsoft.com/en-us/sqlserver/editions/2012-editions/express.aspx

A detailed explanation of SQL Server is beyond the scope of this book, but if you want to find out more, SQL Server Books Online (BOL) is an excellent resource: http://msdn.microsoft.com/en-us/library/ms187875.aspx

For the purpose of installing LightSwitch, the topics that you should be familiar with are

  • Installing an instance of SQL Server, and using Management Studio
  • Creating Databases, Logins, and Users
  • Understanding SQL/Windows authentication, and knowing how to create an ADO.NET connection to your database

image Tip  LightSwitch stores your Intrinsic (Application Data) data in SQL Server, as well as users and roles. It’s important to back up your SQL Server database, because this allows you to restore your application’s data in the event of a disaster. You can refer to Books Online to find out more about backing up and restoring databases.

Using the Publish Wizard

The Publish Wizard is a tool that guides you step by step through the deployment process. You can use the wizard to package or publish your application onto IIS or to publish your application into Windows Azure. To begin the Publish Wizard, right-click your project in Solution Explorer and select the Publish menu option. The first page prompts you to choose the type of application that you want to install (Figure 18-3). Notice how the wizard shows a warning message if you’ve set your active configuration to Debug. When you publish an application, you should set the active configuration of your application to Release by using the drop-down menu that appears in Visual Studio’s toolbar.

9781430250715_Fig18-03.jpg

Figure 18-3. Choosing your application type

The wizard allows you to publish a Desktop or Web application. But in addition to this, you can also choose to publish only the LightSwitch data service. This option is ideal if you’ve written a non LightSwitch application that consumes your LightSwitch data via the OData protocol. If you’ve installed the HTML client, you’ll see two options only on this page: the option to install the “Complete Application,” and an option to install the “Service Only.” If you choose “Complete Application,” LightSwitch publishes all of the clients (Silverlight and HTML client) that exist in your project.

The second page in the wizard allows you to specify where you want to host your server components, as shown in Figure 18-4. As mentioned earlier, you can host your application services in IIS or Azure. But in the case of a Desktop application, you’ll also have the option of hosting your application services locally. If you’ve upgraded your LightSwitch project to include an HTML client, you’ll no longer have the option to deploy your application services locally. So make sure not to add an HTML Client to your project if you want to run your application services locally.

9781430250715_Fig18-04.jpg

Figure 18-4. Choosing where to host the application’s services

The remaining steps in the wizard are all fairly intuitive, and I’ll now explain these in more detail.

image Caution  If you’ve installed the HTML client components, some of the screens that you’ll find in the wizard might look a bit different. For example, the wizard adds the “Certificate” details into a “Security” page rather than show it on a separate page. However, all of these changes are cosmetic, and the concepts that I’ll show you all still apply.

Data Connections Page

If you choose to publish your application, the wizard shows the “Database Connections” page that’s illustrated in Figure 18-5. This page prompts you for two connection strings. The first connection string specifies the connection that LightSwitch uses to connect to your Intrinsic database at runtime. The wizard uses the second connection string during the publishing stage to create and/or update your Intrinsic database. The buttons next to the connection string text boxes open a dialog that helps you to build a connection string.

9781430250715_Fig18-05.jpg

Figure 18-5. Specifying Database Connection dialog

Figure 18-5 highlights the warning that the wizard shows when you enter a connection string that uses integrated security. The Publish Wizard allows you to specify only connection strings that use SQL Server authentication. If you’re not happy with this type of authentication, you’ll find out how to manually set up your application so that it uses integrated security later in this chapter.

If you choose to package your application, rather than publish it, the wizard shows the page that’s shown in Figure 18-6. This page allows you to create a new Intrinsic database or to update an existing database.

9781430250715_Fig18-06.jpg

Figure 18-6. Database Configuration dialog

You’d typically update an existing database if you’re updating an application that you’ve already deployed. When you choose this option, you’ll need to provide a connection string. This allows the wizard to compare your database schema against the existing database and to create an update script.

You might wonder why the wizard doesn’t prompt you to supply database credentials at this point. This is because LightSwitch asks you for the credentials when you actually install the package, and by doing this, it avoids persisting your sensitive credentials in a package file that someone else could get hold of.

Prerequisites Page

If you deploy a two-tier desktop application, you can specify your application’s dependencies by using the page that’s shown in Figure 18-7. By default, your setup package includes the LightSwitch prerequisite component. This component allows LightSwitch to host your application services without IIS being available.

9781430250715_Fig18-07.jpg

Figure 18-7. Install Prerequisites dialog

In addition to the LightSwitch prerequisites, you can also specify additional prerequisites by choosing the “Yes” radio button and using the check boxes to select the items that you want to include. When you do this, the wizard automatically includes the .NET 4 Framework and Windows Installer 4.5 packages. LightSwitch requires the .NET 4 Framework to run, and Windows needs the Windows Installer to install the .NET 4 Framework. The final set of radio buttons allows you to specify the install location for your prerequisites. You can select the option that prompts the user to download the prerequisites from the Internet if you want to reduce the file size of your setup package.

The LightSwitch wizard doesn’t allow you to include your own prerequisites. For example, the wizard allows you to add Microsoft SQL Server Express 2008 R2 and 2012. But if Microsoft releases a newer version of SQL Server or if there are any other components that you want to include, there isn’t any option for you to add them to this list.

Security Page

If you’ve enabled authentication in your application, the Application Administrator tab allows you to specify your application administrator. As I showed you in Chapter 16, authentication allows you to determine the identity of the logged-in user and to secure your application by specifying users, groups, and permissions.

Figure 18-8 shows the page that appears when you enable Forms authentication in the properties of your LightSwitch project. If you enable Windows authentication, the Wizard doesn’t show the full name and password text boxes; it’ll prompt you to enter only a domain user name. In the case of Windows authentication, make sure that you enter your administrator’s user name in a format that includes your domain (for example, DOMAINTIM). If you leave out the domain specifier, LightSwitch assumes that you’re referring to a local Windows user on your database server.

9781430250715_Fig18-08.jpg

Figure 18-8. Application Administrator dialog

If you’re updating an application that you’ve already deployed, you’d choose the radio option that specifies that an application administrator already exists.

image Caution  Remember that if you’re deploying a two-tier desktop application, Forms authentication isn’t secure because a hacker can use the connection string that’s stored locally on your client workstation to connect to SQL Server behind the scenes. For two-tier deployments, I recommend that you use Windows authentication instead.

Digital Signature/Certificate Page

When you deploy a Silverlight application, you can optionally specify a certificate. But what’s the purpose of a certificate, and why would you want to add one? A digital certificate allows you to sign your application’s XAP file—this is the compiled Silverlight application that runs on the end-user’s machine. Signing a XAP file verifies the authenticity of your application and makes it difficult for a hacker to tamper with your application without it being noticed.

If you don’t sign your application, Windows shows a warning when the user installs your application. This warning states that Windows can’t verify the publisher and that your application might be harmful (Figure 18-9). Your users might be scared by this warning, so it’s a good idea to prevent it from showing by signing your application with a certificate.

9781430250715_Fig18-09.jpg

Figure 18-9. Warning Dialog shown during installation

Figure 18-10 illustrates the page that allows you to specify a certificate and sign your application. To obtain a certificate, you can purchase one from a third-party company such as VeriSign or use an internal certificate server if your company has one in place. If you want test the process of signing an application, you can generate a self-signed certificate by using a utility called makecert. You can read more about this and find out the command-line switches that you can use by visiting the following MSDN page: http://msdn.microsoft.com/en-us/library/bfsktky3%28v=vs.80%29.aspx

9781430250715_Fig18-10.jpg

Figure 18-10. Dialog for specifying a certificate

This next page in the wizard is the summary page. This allows you to review your settings and carry on to publish or package your application.

EXERCISE 18.1 – USING THE PUBLISH WIZARD

Open an existing project, and start the Publish Wizard. Work your way through each page in the wizard, and examine the options that you can choose. Pay attention to how the options that the wizard shows changes, depending on the choices that you make earlier in the wizard.

Setting Up Your Web Server

Now that you understand how the Publish Wizard works, this section shows you how to set up and configure a web server. A web server is necessary for browser applications and requires you to carry out the following tasks, which I’ll fully describe in this section:

  1. Install the IIS web server.
  2. Install ASP.NET 4.
  3. Install LightSwitch prerequisites and the Web Deploy Tool.
  4. Configure Application Pools.
  5. Optionally, set up SSL.

The version of IIS that you’ll set up depends on your server’s operating system, and in this section, you’ll find out how to install LightSwitch on Windows 2003 through to Windows 2012.

Setting Up IIS on Windows Server 2008/2012

Windows 2008 comes with IIS7, whereas Windows 2012 includes IIS8. Both of these operating systems allow you to set up IIS by using the “Server Manager” application. Once you open Server Manager, go to the Roles Summary group, and click on the Add Roles link (shown in Figure 18-11). This opens the “Add Roles Wizard,” and you’ll find a page in this wizard that allows you to select the Web Server (IIS) server role.

9781430250715_Fig18-11.jpg

Figure 18-11. Adding the IIS Server Role

Once you complete the “Add Roles Wizard,” Server Manager adds a “Web Server (IIS)” section inside the Roles group as shown in Figure 18-12.

9781430250715_Fig18-12.jpg

Figure 18-12. Adding Role Services in Windows 2008/2012

In the Role Services pane, enable the following three Role Services, as highlighted in Figure 8-12:

  • Management Service
  • Application Development image ASP.NET
  • Security image Windows Authentication

Setting Up IIS on Windows 8, 7, or Vista

To set up IIS on a client operating system, you’ll need to enable IIS in Windows Control Panel rather than add the “Web Server Role” as in the case of a server operating system. When you open Control Panel, select “Programs and Features” and choose the option to “Turn Windows features on or off.” When the Windows Features dialog opens (Figure 18-13), select the options “Management Service,” Application Development Features image ASP.NET, and Security image Windows Authentication.

9781430250715_Fig18-13.jpg

Figure 18-13. Turning Windows features on or off in Control Panel

Setting Up IIS 6 on Windows 2003

To set up IIS6 on Windows 2003, you’ll need to install it by using the “Add/Remove Windows Components” option that you’ll find in Windows Control Panel. When the “Windows Component Wizard” dialog opens, select “Application Server” and click on the Details button to open up the dialog that’s shown in Figure 18-14. When you click on the OK button, Windows might ask you to insert the Windows 2003 CD that matches the exact edition of Windows 2003 that you’re using. For example, if your server runs “Windows 2003 Standard, Volume License Edition, with SP2,” you’ll need the CAB file from that specific CD, and a CAB file from a different edition might not work. It might be difficult to locate the correct CD, particularly if the person who originally installed your server has now left, which is quite likely in a case of an operating system that’s now 10 years old. If this is the case, we wish you good luck in finding your installation CD!

9781430250715_Fig18-14.jpg

Figure 18-14. Enabling IIS6 on Windows 2003

After you’ve installed IIS6, you’ll need to install ASP.NET and the LightSwitch prerequisites. (I’ll explain how to do this very shortly.) Once you’ve installed ASP.NET 4, it’s important to make sure that it’s enabled in the “Web Service Extensions” section of Internet Information Services (IIS) Manager, as shown in Figure 18-15.

9781430250715_Fig18-15.jpg

Figure 18-15. Enable the ASP.NET v4 Web Service Extension

Setting Up IIS Application Pools

Application pools improve the reliability of your web server by isolating the applications that run in IIS. If a web site in an application pool crashes, it won’t bring down the other web sites that run in other application pools. It therefore makes good sense to deploy each LightSwitch application into its own separate application pool.

Each application pool also runs under a specific security context, and this enables you to configure your application services to connect to your SQL Server database through Windows Authentication. Figure 18-16 illustrates this concept.

9781430250715_Fig18-16.jpg

Figure 18-16. Set up an Application Pool to Windows Authenticate to SQL Server

To create a new application pool, open Internet Information Services (IIS) Manager and right-click the Application Pools node on the navigation menu on the left. You’ll find a right-click context menu option that allows you to create a new application pool, as shown in Figure 18-17. It’s important to set up your Application Pool to use version 4 of the .NET Framework.

9781430250715_Fig18-17.jpg

Figure 18-17. Creating an Application Pool in IIS7

In IIS7 and above, it is also preferable to choose the Integrated Managed Pipeline Mode, as opposed to Classic Mode. Classic mode is primarily designed for legacy code that might not run properly in integrated mode. Your LightSwitch server runs more efficiently when you set the pipeline mode to integrated.

After you deploy your web site, you can configure it to use the Application Pool that you’ve added by modifying the web-site properties in IIS Manager.

Configuring SQL Server Windows Authentication

Your LightSwitch application services can authenticate onto SQL Server by using two types of authentication: SQL Server authentication or Windows authentication. SQL Server authentication uses SQL Server to store and manage the login and password credentials. If you use SQL Server authentication, you’ll need to hard-code your SQL server login and password in the connection string that LightSwitch uses to connect to your database. Because your login name and password are hard-coded in a plain text file, some IT departments regard SQL Server authentication as less secure than Windows authentication. If you want to read more about the pros and cons of SQL Server authentication vs. Windows authentication, you can find out more in the following TechNet article http://technet.microsoft.com/en-us/library/ms144284.aspx.

To use Windows authentication, you’ll need to first create a Windows domain user. If your IIS server and SQL Server are on the same machine, you might find it easier to create a local Windows user rather than a domain user (particularly if you don’t have sufficient permissions to create new domain users).

Select the application pool that your application uses, and open the “Advanced Settings” dialog. Open the “Application Pool Identity” dialog by clicking the button that you’ll find next to the Process Model image Identity text box. When the dialog opens, choose the “custom account” radio button (Figure 18-18), and use the “Set” button to specify the Windows user who you want to use.

9781430250715_Fig18-18.jpg

Figure 18-18. Changing the Application Pool Identities

The Windows user who you specify needs to have NTFS read permissions on the folders where you’ve installed your LightSwitch application. You should also add the user to the local IIS_IUSRS group in order to grant access to the ASP.NET resources that are needed.

The last step is to make sure that you add a SQL Server login for your Windows user by using SQL Server Management Studio. You’ll also need to grant access permissions to the tables in your application and grant access rights to the tables that the ASP.NET membership provider uses. The quickest way to do this is to add your user into the following database roles:

  • aspnet_Membership*
  • aspnet_Roles*
  • db_datareader
  • db_datawriter
  • public

Windows authentication should now work, but if it doesn’t, you might need to configure the NTLM provider or carry out some extra steps to configure Kerberos authentication. The following TechNet article will help you if you run into problems: http://technet.microsoft.com/en-us/library/dd759186.aspx.

Configuring Secure Sockets Layer (SSL)

The LightSwitch client communicates with your web server via the HTTP protocol—a clear text protocol. If a hacker monitors your network, they’ll be able to see your LightSwitch data as it passes through the network. This poses a security vulnerability, particularly if your application uses Forms authentication. A hacker can easily discover user-name and password combinations by monitoring the network while users log in. To mitigate this vulnerability, you’d encrypt your data over the network by using the HTTPS protocol.

To set up HTTPS, you’ll need to install an SSL (Secure Sockets Layer) certificate on your web server. This certificate verifies the identity of your server and contains the keys that SSL uses for encryption. You can either purchase a certificate from a third-party company, such as VeriSign, or use an internal certificate server if your company has such infrastructure in place. The Server Certificates option that you’ll find in IIS Manager allows you to request, install, and configure SSL certificates.

An SSL certificate is valid when it meets the following three conditions: the server name on the certificate matches the server on which it’s installed, the certificate is within its validity period, and the certificate is signed by a trusted Certificate Authority. What tends to happen is that administrators allow certificates to expire by not renewing them in sufficient time. It’s important not to let this happen because desktop applications won’t work if your web server’s SSL certificate becomes invalid. The security model in Silverlight prevents LightSwitch applications from connecting to web servers with invalid certificates, and there’s no way that you can circumvent this security feature. Silverlight browser and HTML client applications will still work, but the browser warns the user that they “might be visiting a dangerous website.” This doesn’t look very professional, so it’s good practice to make sure that your SSL certificates don’t lapse.

If your application stores sensitive data, you might want to enforce encryption on all network traffic that takes place between your client and the server. This is particularly useful on LightSwitch applications that you expose over the public Internet. You can mandate SSL for all traffic by modifying your web.config file as shown in Listing 18-1. When you deploy your application, you’ll find this file in the root folder of your ASP.NET application.

Listing 18-1.  Web.config Setting to Mandate SSL

<configuration>
  <appSettings>
    <!-- A value of true will indicate http requests should be
         re-directed to https -->
    <add key="Microsoft.LightSwitch.RequireEncryption" value="true" />

Microsoft Web Platform Installer

After you install IIS, the Web Platform Installer (or Web PI) is the easiest way to install the remaining components on your server. You can obtain Web PI from the following web site:
http://www.microsoft.com/web/downloads/platform.aspx

Once you install and start Web PI, you can use the search feature to find and install “ASP.NET 4.5” (Figure 18-19). Once you’ve installed ASP.NET, do a search on “LightSwitch” to find the server configuration components. You’ll find a couple of search results for LightSwitch 2012: a Server Configuration package that includes SQL Express, and a package that doesn’t. If you already have a SQL Server that you can use, you can choose the package without SQL Express.

9781430250715_Fig18-19.jpg

Figure 18-19. Installing the prerequisites using Web PI

Note that you must install ASP.NET or .NET 4.5 in order for the LightSwitch 2012 Server Configuration options to appear in Web PI.

ASP.NET Configuration

Although Web PI provides an easy way for you to set up your server, some companies might have policies that stop you from installing tools like Web PI on production servers. Another reason that can prevent you from installing Web PI is that your server might not have Internet access—this isn’t unusual on servers in locked-down, secure environments. In these circumstances, you can install ASP.NET by downloading the full Microsoft .NET 4 Framework redistributable from the Microsoft web site: http://www.microsoft.com/download/en/details.aspx?id=17718

ASP.NET might not work if .NET 4 already exists on your server and you install IIS afterward. In this situation, ASP.NET might not be registered correctly, but you can correct this by opening a command prompt and running the aspnet_regiis.exe command. You can find this utility in the following folder:

  • On a 32-bit server: <WindowsDir>Microsoft.NETFrameworkv4.0.30319
  • On a 64-bit server: <WindowsDir>Microsoft.NETFramework64v4.0.30319

Once you’ve navigated to the correct folder, run the command with the i switch (that is, aspnet_regiis.exe –i) to re-register ASP.NET. You can also use the same process to reinstall or repair ASP.NET.

Installing the LightSwitch Server Components

If you’re unable to install Web PI on your server, you can download the LightSwitch 2012 Server Configuration Component from another machine and copy it onto your server. You can find the most up-to-date URL by running Web PI outside of your server, adding the “Server Configuration Component,” clicking on the “Items to be Installed” link, and clicking the “Direct Download” link. At the time of writing, the URL is http://go.microsoft.com/fwlink/?LinkID=213906

Using the Microsoft Web Deploy Tool

If you want to directly publish a LightSwitch application from Visual Studio, or install the packages that the Publish Wizard generates, you’ll need to install the Microsoft Web Deploy Tool. You can use Web PI to install this utility, or you can download it directly from the Microsoft IIS web site (http://www.iis.net/download/WebDeploy).

The Web Deploy Tool installs a Web Deployment Agent Service. For publishing to work, it’s important to ensure that this service is started (shown in Figure 18-20). Although the installer sets the startup type of this service to Automatic, you should manually check that the service is started if you experience problems publishing your application.

9781430250715_Fig18-20.jpg

Figure 18-20. The Web Deployment Agent Service must be started

Installing the Packages

Now that you know how to build a web server with all the necessary components, this section shows you how to install the packages that you created with the Publish Wizard.

Installing a Two-Tier Desktop Application

When you use the Publish Wizard to build a two-tier desktop application, the wizard produces a set of installation files in the output folder that you specified in the wizard. The publish output includes a file called Setup.exe, and this is the application that you would run on the client workstation to install your application. If you’ve specified any prerequisites in the Publish Wizard (such as the .NET 4.5 Framework), Setup.exe will install these components too. But before you run Setup.exe, you’ll need to carry out the following data tasks:

  1. Create your SQL Server Database.
  2. Modify your application’s database connection string.

Installing Your SQL Database

The output from the Publish Wizard produces a SQL script called <YourApplication>.sql (where <YourApplication> is the name of your LightSwitch application). This script creates the database, tables, stored procedures, and other database objects that support your application. You’ll need to execute this script on your database server, either by using the sqlcmd command-line tool or SQL Server Management Studio.

If you’ve installed a basic instance of SQL Server Express without the Management Tools, sqlcmd is the method that you would use. The default location of this utility on a 64-bit machine is

Program Files(x86)Microsoft SQL Server100ToolsBinn

To use sqlcmd, open an elevated command prompt, navigate to the directory where it’s installed, and run the following command:

sqlcmd.exe -i Helpdesk.sql -S .SQLExpress

You’ll need to replace the arguments that you supply to sqlcmd.exe as follows:

  • -i Helpdesk.sql: This specifies the SQL file that you want to execute. Replace this with the name of the SQL file in your publish folder.
  • -S .SQLExpress: This specifies the name of your database server and SQL Server instance.
  • -U <username> -P <password>: If you don’t specify the –U and –P switches, sqlcmd connects to your SQL Server instance using Windows authentication. These switches allow you to supply a user name and password if you want to use SQL authentication instead.

If you choose to install the SQL Script by using SQL Server Management Studio, make sure to place your query window into SQLCMD Mode by using the option that you’ll find under the Query menu. Your script won’t run correctly if you don’t do this.

Setting the Database Connection String

If you specify a correct and valid connection string in the Publish Wizard, you can skip this step. But if not, you’ll need to modify your application’s connection string so that it points to the database that you’ve installed. The publish output contains an “Application Files” subdirectory that includes a file called web.config. Open this file in Notepad, and edit the connection string value in the <connectionStrings> section like so:

<add name="_IntrinsicData" connectionString="Data Source=SERVERNAMESQLEXPRESS;
   Initial Catalog=HelpDeskDB;Integrated Security=True;Pooling=True;
   Connect Timeout=30;User Instance=False" />

Replace SERVERNAMESQLEXPRESS with the name of your database server and instance, and replace HelpDeskDB with the name of your database. If you’ve defined additional data sources in your application, you’ll find the connection strings in the same section of the web.config file, and you can modify them as appropriate.

If you’ve enabled authentication in your application, you will have defined your application’s administrator in the Publish Wizard. You’ll find the settings that relate to your application’s administrator in the web.config file, and you can also modify the values manually if needed.

Once you configure these data tasks, you’ll be able to successfully run setup.exe on your client workstation. This creates a shortcut on the desktop, and the user can use this to start your application.

image Note  LightSwitch 2011 included a utility called Microsoft.LightSwitch.SecurityAdmin.exe that helped you set up Administrators. LightSwitch 2012 no longer includes this utility.

Installing a Three-Tier Browser and Desktop Applications

When you use the Publish Wizard to create a three-tier browser or desktop application, the wizard produces a single zip file rather than a set of files that includes an installer, as in the case of a two-tier application. The wizard names your zip file after your application (for example, HelpDesk.zip). This zip file is the package that the “IIS installer” consumes, and to use it, you’ll need to install the “Web Deploy Tool,” as I explained earlier.

To install the package, copy the zip file onto your server. Open IIS Manager, use the panel on the left to navigate to your web server, and select the right-click Install option. This opens the “Import Application Package” wizard, and the first page will prompt you to enter the path to your zip file. The next page shows you the package contents and allows you to review the items that the wizard will install (Figure 18-21). The default items include the SQL Script that defines your Intrinsic database, the option to create an IIS application, and the option to install the actual web files. You’ll want to select all of these options.

9781430250715_Fig18-21.jpg

Figure 18-21. Import Application Package dialog—first page

The next page (shown in Figure 18-22) allows you to specify your database connection strings. The first “Connection String” text box specifies the connection string that the wizard uses to install or update your Intrinsic database. The next text box allows you to specify the connection that IIS uses at runtime to connect to your Intrinsic database. The wizard provides DatabaseUserName and DatabaseUserPassword text boxes because it expects you to use SQL Server authentication. If you want to use Windows authentication, you’ll need to manually modify your web.config file after the import tool finishes and set up an application pool in IIS, as described earlier.

9781430250715_Fig18-22.jpg

Figure 18-22. Import Application Package—database connection strings

Once you complete all the steps in the “Import Application Package” wizard, your application will be installed. If everything has worked correctly, you’ll be able to open a web browser and navigate to the URL where you’ve installed your application.

In the case of a desktop application, you’ll see an installation page like the one that’s shown in Figure 18-23. When the user clicks on the “Install HelpDesk” button, the “Click Once” installer installs your desktop application and creates a desktop icon.

9781430250715_Fig18-23.jpg

Figure 18-23. Out-of-browser application install page

Three-Tier Manual Deployment

Although the wizard provides a rich graphical way for you to deploy an application, you can just as easily deploy your three-tier application manually rather than create a zip file and use the Web Deploy Tool. If you’re a traditional developer and like working in the “old school” way, this technique will suit you well. If you know what you’re doing, it’s quicker than using IIS’s “Import Application Package” wizard and working through each page one by one.

The server-side part of your LightSwitch application is simply an ASP.NET web site. Instead of relying on the “Import Application Package” wizard to create your web site, you can create one manually by using IIS Manager. You would then need to use the option in IIS Manager to create an application and configure it to use an application pool that targets the .NET 4 Framework.

To publish your application, you’ll still need to use the Publish Wizard from within LightSwitch. Once you’ve completed the wizard, you’ll find your published files in the folder binReleaseapp.publish. You can now simply copy the contents of this folder into the folder for your web site. Before you run your application, you might need to modify the database connection strings in your web.config file so that they point to the right data source.

Deploying Data

When you were writing your application, you might have added records into your Intrinsic database that you now want to deploy. Although the Publish Wizard deploys the schema of your database, it won’t deploy the data that you entered at design time.

You know that the Publish Wizard creates a SQL Script that contains the schema of your database, so the easiest way to deploy your data during the setup process is to add SQL INSERT statements to the end of this script file.

If you want to retrieve the data that you entered into your design-time database, you can attach your database’s .MDF file by using SQL Server Management Studio. Management Studio includes a feature that allows you to script the data in your tables. To use this feature, right-click your database in Object Explorer and start the “Script Wizard” by selecting Tasks image Generate Scripts. When you reach the options page, set the “Script Data” option to true. When the wizard completes, you can copy the SQL INSERT statements that the Script Wizard creates into the clipboard and paste them to the end of your deploy script.

Updating an Application

To update an application that you’ve deployed, you can simply run the Publish Wizard again. Each time you use the Publish Wizard, LightSwitch automatically increments the version number of your application. If you’ve changed the schema of your database, you can select the option in the Publish Wizard to “update an existing database.” When you choose this option, the wizard creates a change script that updates only the database objects that have changed.

In a three-tier setup, you would install your updated version over your old version. Web clients will automatically run the latest version that’s hosted on your web site, and desktop clients will detect that a new version is available and install it.

Troubleshooting Deployment Errors

Unfortunately, applications don’t always deploy smoothly, and sometimes it’s very difficult to diagnose the exact cause of a problem. When you deploy a three-tier application, the cause of any problem will often be down to three reasons: a problem with IIS’s configuration, a problem with your LightSwitch components, or a problem with database connectivity. Figure 18-24 illustrates some of the errors that you might encounter.

9781430250715_Fig18-24.jpg

Figure 18-24. LightSwitch deployment errors

The first error in Figure 18-24 shows an IIS error. If your browser returns an HTTP error code that’s generated by IIS, it means that you have some sort of IIS misconfiguration. This could be due to permissions or application pool settings. In the case of an IIS error, you can use the HTTP error code to diagnose your problem, and you should also check the Windows Event Log for additional details. Instead of an IIS error, you might encounter what’s known as the “yellow screen of death”—this is a reference to the error page that ASP.NET generates. If this happens, it suggests that you’ve configured IIS and ASP.NET correctly, but there’s some problem that’s caused by the way that your application is set up in IIS. The error message that ASP.NET returns should hopefully help you diagnose the exact cause of the problem.

The second screenshot in Figure 18-24 illustrates a case where the Silverlight client loads successfully, but the application doesn’t load any further. GetAuthenticationInfo is the first server method that your Silverlight Client calls, and because of this, it’s common to see error messages that refer to this method. But deceptively, your problem might have nothing to do with authentication, and the best way to diagnose this problem is to trace your application. (The next section shows you how to do this.)

The final type of problem that you might encounter is the dreaded “red X” problem. This is a condition where your application loads successfully, but red crosses appear instead of data. Usually, this indicates a database or network connectivity problem. A classic symptom is that your screen shows the spinning hourglass for 30 seconds before it fails and shows the “red X.” This 30-second period corresponds with SQL Server’s default connection-timeout period of 30 seconds, and it highly suggests a database connection problem. If you see a “red X” on your screen, try opening a screen that contains a custom screen query that you’ve written in code. When a LightSwitch control such as DataGrid experiences a data problem, it “swallows” the exception and displays a “red X.” But when a code query experiences a problem, it’ll raise an unhandled exception, and LightSwitch will open the exception details in a dialog box. The error message that you’ll see includes the exact exception (for example, SQL Exception Timeout Exception), and you can use this to confirm whether or not you have a general database connectivity problem.

Tracing Your Application

LightSwitch includes a diagnostic subsystem that integrates with ASP.NET’s tracing functionality. You can use this feature to help you diagnose errors, resolve configuration issues, or work out why a query has failed. The trace messages that LightSwitch produces include the server request, the server response, and an error description.

For performance and security reasons, LightSwitch turns off tracing by default. To turn it on, you’ll need to make some changes to your web.config file. Listing 18-2 shows the sections in your web.config file that apply to tracing.

Listing 18-2.  Trace Settings in Web.Config

<appSettings>
 <!-- A value of true will enable diagnostic logging on the server -->
 <add key="Microsoft.LightSwitch.Trace.Enabled" value="true" />         images
 <!-- A value of true only lets local access to Trace.axd -->
 <add key="Microsoft.LightSwitch.Trace.LocalOnly" value="true" />       images
 <!-- The valid values for the trace level are: None, Error, Warning,
       Information, Verbose -->
 <add key="Microsoft.LightSwitch.Trace.Level" value="Information" />    images
 <!-- A value of true will indicate that logging sensitive information is ok -->
 <add key="Microsoft.LightSwitch.Trace.Sensitive" value="false" />      images
 <!-- The semi-colon separated list of categories that will be enabled at the
       specified trace level -->
    <add key="Microsoft.LightSwitch.Trace.Categories"
      value="Microsoft.LightSwitch" />
 <!-- Other web.config details here…… -->
  
<system.web>
    <!-- LightSwitch trace.axd handler -->
    <trace enabled="true" localOnly="false" requestLimit="40"           images
       writeToDiagnosticsTrace="false"
       traceMode="SortByTime" mostRecent="true" />

Let’s take a closer look at some of these settings:

  • Enabled - images: You need to set this value to true to turn on tracing.
  • LocalOnly - images: When you set this to true, you can view trace messages only when you’re logged on to your web server. If you set this to false, you’ll be able to view the trace data from outside of your server, but note that this is a less secure setting.
  • Level - images: This setting allows you to specify the amount of information that LightSwitch logs. For diagnostic purposes, I recommend setting this to verbose. This is the setting that retrieves the maximum amount of information.
  • Sensitive - images: This setting controls whether or not LightSwitch can include your table data in its trace output. If you set this to true, LightSwitch may write sensitive data (for example, addresses, balances, prices) into the trace log.

The final change that you need to make is to enable ASP.NET’s trace.axd handler images. You’ll find this setting lower down in the file, inside the system.web group.

Once you modify your web.config file, you can view your application’s trace by opening a browser and navigating to your web site’s trace.axd page (for example, http://MyWebServer/MyApp/trace.axd). When this page opens, you’ll be able to view a list of trace messages, and you can view additional details by clicking on the View Details link. Figure 18-25 shows an example of the trace output that LightSwitch produces. Notice how the trace records all calls to the data service, and entries 5 and 6 in Figure 18-25 highlight calls to the data service’s Engineers and Issues methods.

9781430250715_Fig18-25.jpg

Figure 18-25. Trace.Axd page

Deploying to Azure

A great feature of LightSwitch is that you can easily deploy applications to Windows Azure—an Internet cloud-based platform. An excellent use-case scenario is to build an HTML client application and to host your application services in Azure. This allows your users to access your application “on the road” by using a mobile phone or tablet device that connects to the Internet via a cellular connection. Other advantages of Azure include simplicity, easier maintainability, and scalability.

Earlier in this chapter, you learned how to set up IIS and, hopefully, this hasn’t been too difficult for you. Unfortunately, setting up a web server can be quite tricky, particularly if you don’t have much experience of IIS. To make your application work, you need to install all the necessary components, configure permissions correctly, and make sure that you don’t have firewall or antivirus rules that block your HTTP traffic. If you get this wrong, you can find yourself fighting with errors that can be quite obscure—Azure saves you from all of this trouble.

Another benefit of Windows Azure is that it’s easier to maintain your underlying infrastructure. If you (rather than someone else in your company) are responsible for managing your own web server, you’ll appreciate Azure much more. You’ll no longer need stay at work late every “patch Tuesday” to install Windows Updates, struggle to work out why your server suddenly starts performing sluggishly, or end up being forced to replace a failed hard disk at the most inconvenient moment.

Azure also provides scalability. If you need more performance during busy times, you can simply use the web portal to provision more resources (and pay more money, of course). When demand goes down, you can scale back down again.

To get started, you’ll need to log in to the Windows Azure web site (http://www.microsoft.com/windowsazure/) and sign up for an account. Windows Azure is priced on a “pay as you go” basis, so it’s a good idea to study the pricing details that you’ll find on the web site before you carry on. If you’re new to Windows Azure, Microsoft provides a free 90-day trial. This is a great way to test out the service. When you sign up to the service, you’ll need to enter a credit card number so that Microsoft can bill you after the initial 90-day period. If you intend only to try the service, remember to cancel your subscription before your trial period expires.

Once you’ve created an account, you’ll find it surprising easy to publish to Azure. You simply choose the “Azure” option in the Publish Wizard and allow the wizard to guide you through the process, step by step. Let’s now examine the publishing process by walking through the steps that you’ll find in the wizard.

Connecting Visual Studio to Azure

Once you start the Publish Wizard, the second page prompts you to choose where to host your application’s services—select the Windows Azure option. If you’ve installed the HTML client, the wizard prompts you to download and install the latest “Windows Azure SDK.” Once you’ve installed this SDK, you can resume the wizard and enter your Azure details. This page will prompt you to create a new “publish setting” entry. When you choose this option, the wizard opens the dialog that’s shown in Figure 18-26.

9781430250715_Fig18-26.jpg

Figure 18-26. New Subscription dialog

The first drop-down box allows you to create or select an authentication certificate. Once you select a certificate, click on the “Copy the full path” link to copy the file location of your certificate onto the Windows clipboard.

You’ll now need to move away from the wizard by logging in to the Azure Portal. Go to the Settings section, and click on the option to “Upload a Management Certificate” (Figure 18-27). While you’re in the Azure Portal, make a note of your Azure Subscription ID, which you’ll find in the accounts section. Your subscription ID is a GUID that uniquely identifies your Azure account. Once you’ve made a note of this, you can return to the wizard and enter this value into the third text box in the “New Subscription” dialog. Once you’ve entered all of the details that are shown in this dialog, Visual Studio is authorized to publish your application to your Azure account.

9781430250715_Fig18-27.jpg

Figure 18-27. Installing a new management certificate

Choosing an Azure Service Type

The next step in the wizard prompts you to choose a service type, and there are two types that you can choose from: a Web Site Service or Cloud Service (Figure 18-28).

9781430250715_Fig18-28.jpg

Figure 18-28. Choosing a Service Type

Azure’s Web Site service provides simple hosting and is suitable for most LightSwitch applications. The Web Site service provides a hosted IIS environment, and to give an analogy, this type of service competes with services that are generally offered by web-hosting companies. Once you create a web site, you can increase performance by using the portal to dynamically add additional web-site instances. Azure will automatically load-balance the web requests between the web-site instances that you’ve created.

A Cloud Service is an example of what’s commonly called Platform as a Service (PaaS). This service type provides you with a virtual machine that you can “remote desktop” onto. The advantage is that you can install your own applications, modify registry settings, and more easily debug your server-side code by logging in to your server.

After you select your preferred service type, the wizard opens a page that prompts you to select the name of the Web Site or Cloud Service that you want to use. If you’ve not created a Web Site or Cloud Service, the page in the wizard includes a hyperlink that takes you directly to the Azure Portal to allow you to create a service.

Figure 18-29 illustrates the page that the wizard shows you when you select the Cloud Service option. Notice the check box in the screen that allows you to enable Remote Desktop. If you enable Remote Desktop, the “Settings” link allows you to define the user name and password credentials for establishing a remote desktop connection.  If you select the Cloud Service option, you’ll need to specify a storage service in the “Advanced” tab, and the Azure Portal allows you to create this. A storage service defines the place where Azure stores your application binaries.

9781430250715_Fig18-29.jpg

Figure 18-29. Setting up a Cloud Service

Creating a Database

After setting up the “application hosting” part of your application, the next step is to create the database that supports your application. Figure 18-30 shows the page in the wizard that prompts you to specify your Database connection. You’ll notice that the page includes a link that allows you to “Provision a database at the Azure Portal.” This link opens the Azure Portal in a new web browser window, and you can navigate to the “SQL Databases” part of the portal to create a new Azure database.

9781430250715_Fig18-30.jpg

Figure 18-30. Setting up your database

When you add a new SQL database, you’ll need to define an administrative user name and password, specify a database name, and set the maximum size of your database in gigabytes. The size that you choose partly determines the price that you’ll need to pay for the Azure service.

After you’ve created your database, Figure 18-31 shows a screenshot of your database’s “Dashboard” in the Azure portal. In the “quick glance” section that appears toward the bottom right, you’ll see two useful links: Show connections strings, and Manage allowed IP addresses.

9781430250715_Fig18-31.jpg

Figure 18-31. Managing your database

The “Show connections strings” link opens a dialog that shows you a connection string that you can copy and paste into the Publish Wizard’s “Specify the user connections” text box.

For security reasons, SQL Azure includes a built-in firewall that restricts access to your database by IP address. If you want to establish a connection to your SQL Azure database from your development PC (using Management Studio, for example), you’ll need to add a firewall exception before you can do this. You can create firewall exceptions by clicking on the “Manage allowed IP addresses” link.

Completing the Publishing Process

The remaining steps in the wizard allow you to specify an HTTPS certificate and to sign your XAP file with a digital certificate (in the case of a Silverlight application). Once you’ve completed all the steps in the wizard, you can click on the “Publish” button and complete the deployment of your application to the Azure platform. Hopefully, this section highlights how easy it is to deploy your applications to Windows Azure.

If you want to expose your application over the Internet, Windows Azure is a great choice, but it isn’t the only option. You shouldn’t overlook the services that web-hosting companies offer. The web-hosting market is competitive, and there are many companies that can host your LightSwitch application for a cheaper price.

You should also consider the security and privacy implications of exposing your application over the Internet. If you expose your application over the Internet, it’s up to you to review the sensitivity of your data and to risk-assess the impact that a data breach could have on your business.

With Windows Azure, you should also be aware that because Microsoft is a US company, any data that you store in Azure might be subject to interception by US authorities. You won’t be too shocked by this if you live in the US, but if you live in Europe (for example), you might want to do an Internet search on “US PATRIOT Act” to read more about the impact of choosing to use a US firm for processing and storing your data.

Publishing to SharePoint

Visual Studio 2012 Update 2 introduces the option to host your Silverlight or HTML client applications in SharePoint 2013 or Office 365.

Hosting your application in SharePoint 2013 can be beneficial if your organization already uses SharePoint. One advantage is that you can customize your LightSwitch application so that it integrates more closely with your SharePoint system. For example, you can implement authentication using SharePoint identities and permissions, or create list items, create workflows, or add images to SharePoint picture libraries.

The SharePoint client object model (CSOM) is the API you use to write code that integrates your LightSwitch application with SharePoint. You can find out more about CSOM on the help page: http://go.microsoft.com/fwlink/?LinkId=285361.

The quickest way to get started is to create a SharePoint developer site on Office 365. You can find out how to do this by visiting the following web page: http://go.microsoft.com/fwlink/?LinkId=263490.

Once you’ve prepared your SharePoint or Office 365 web site , the first step is to enable the SharePoint feature in your LightSwitch project. You’ll need to upgrade your project, and once you do this, your application’s properties will include a SharePoint tab (Figure 18-32). When you click on the “Enable SharePoint” button, LightSwitch prompts you to download and install the “Microsoft Office Developer Tools for Visual Studio” package.

9781430250715_Fig18-32.jpg

Figure 18-32. Enabling SharePoint

Clicking the “Enable SharePoint” button prompts you to enter the URL and security credentials for your Office 365 or SharePoint site. Once you do this, LightSwitch adds a new project into your solution, and it also adds references to several supporting assemblies.

If you now debug your application, LightSwitch uses SharePoint to provide authentication, and then it redirects you to an instance of your application that’s hosted locally in IIS Express. When you debug your application for the first time, LightSwitch prompts you to install a self-signed certificate to support SSL.

To deploy your application to SharePoint, simply run the LightSwitch Publish Wizard . You’ll notice that the wizard now shows only one page. The instructions in the wizard describe how the process works (Figure 18-33), and it provides you with the following two hosting options: Autohosted or Provider-hosted. When you deploy an autohosted application in Office 365, the process automatically hosts your application in Windows Azure and hosts your Intrinsic database in SQL Azure. When you complete the Publish Wizard, LightSwitch generates a file called <YourProject>.SharePoint.app.

9781430250715_Fig18-33.jpg

Figure 18-33. Running the publish wizard

To finish the deployment, you’ll need to open your SharePoint site in a web browser, navigate to the “Apps in Testing” section, and click on the “new app to deploy” link (Figure 18-34). This opens a dialog that allows you to upload the <YourProject>.SharePoint.app file that you created with the Publish Wizard.

9781430250715_Fig18-34.jpg

Figure 18-34. Uploading your app

After you upload your application, you’ll see another dialog that prompts you to deploy your application. After you click on the deploy button, you’ll be able to run your application by clicking the link that appears in the “Apps in Testing” section.

Summary

This chapter has showed you how to deploy LightSwitch applications. It’s possible to create many different types of applications, which results in several distinct deployment combinations. LightSwitch applications depend on application services that you can install on an IIS server, on Azure, or on the client workstation. You can install your application services on the client only if you’re building a desktop application. This deployment scenario is ideal for stand-alone applications or applications that do not have many users. However, there’s a larger deployment overhead because you’ll need to install the application services on each workstation that needs to access to your application.

If you’re building a browser application, you must host your application services in IIS or Windows Azure. If you choose to host your application in IIS, there are several setup tasks that you need to carry out. First, you need to install IIS, and the exact way to do this depends on your server’s operating system. A tool called Web Platform Installer (Web PI) allows you to download and install the remaining components that are required to host a LightSwitch application. You can download Web PI from the Microsoft web site. The items that you’ll need to install on your server are ASP.NET 4, the “LightSwitch 2012 Server Configuration” component, and the Web Deploy Tool. If you’re unable to install Web PI on your web server, you can download the components on a separate computer and copy them onto your server.

Other relevant IIS settings include setting up SSL and adding application pools. SSL makes your application more secure by encrypting the data between your LightSwitch client and server. Application pools improve reliability by isolating the applications that run on your web server. If a web application crashes, it won’t bring down other web applications that run in other application pools. Application pools also allow you to set up your data service to use Windows authentication with your SQL Server instance.

LightSwitch includes a “Publish Wizard” that allows you to deploy your application. This contains a series of screens that guide you step by step through the deployment process. If you’re deploying an application to IIS, you can choose to either package or publish your application. The difference between publishing and packaging is that publishing deploys an application immediately to your IIS server, whereas packaging produces setup files that you need to manually install afterward. In the case of Silverlight applications, the Publish Wizard allows you to digitally sign your XAP file. If you don’t do this, Windows shows a dialog when your user installs your application that warns that your application might be dangerous. You can prevent this warning by signing your application with a digital certificate.

If you choose to deploy a three-tier application, the Publish Wizard either publishes your application or produces a deployment zip file. If you create a package, you can use IIS’s “Import Application Package” wizard to install your package. This wizard takes care of setting up your application service’s web site and creating the SQL Server database that supports your application. Once you’ve added your application to IIS, your users can run your browser application or install your desktop application by navigating to your application’s URL through a web browser.

In the case of a two-tier desktop application, the Publish Wizard produces a file called Setup.exe, along with a script that creates your database and supporting database objects. To install your application, you’ll need to run the script against your database server and run the setup.exe file on the client workstation.

To update an existing application, you can simply re-run the wizard. The Publish Wizard can analyze your existing database and produce a SQL script that applies the incremental schema changes that you’ve made.

The Publish Wizard also allows you to deploy your application to Windows Azure. Azure is a cloud service that you can use to publish applications that users can access through the Internet. The service works on a “pay as you go” basis, and the cost depends on the resource and network utilization of your application. To use Azure, you’ll need to set up an account by using the Azure web portal. You can host your application by using either a “Web Site,” or Cloud service. An Azure “Web Site” provides simple hosting, whereas the Cloud service provides an environment that supports “remote desktop” and allows you to install custom software. The publishing process requires you to authorize your copy of Visual Studio with your Azure account by adding a management certificate through the Azure Portal web site. You also need to provision a “Web Site” or Cloud service and a SQL Azure database. You can carry out both these tasks through the Azure Portal.

Finally, you can host your application in SharePoint or Office 365 by installing Visual Studio 2012 Update 2. One of the advantages of hosting your application in SharePoint is that you can integrate your application with lists, libraries, and other SharePoint assets.

Sadly, this brings us to the end of the book. I hope that you’ve found it useful; well done for persevering through all 18 chapters! You’re now capable of building some excellent LightSwitch applications, and I wish you the very best of luck in all of your future LightSwitch projects.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.99.71