Deploying
applications to Windows Azure is basically a publishing process similar
to the one that involves classic ASP.NET applications, but it differs
in the target place (the cloud) and in the application files.
Right-click the Azure project in Solution Explorer (in our example it
is AzureBookstore) and click Publish
in the pop-up menu. Visual Studio generates a Publish subfolder under
the Bin\Debug or Bin\Release (depending on your output configuration)
where required files are stored; moreover, Visual Studio launches
Windows Explorer pointing to this new folder so that you can easily
understand what files are required. Also, Visual Studio launches your
Web browser opening the Windows Azure Developer Portal (http://windows.azure.com) on the Internet, which is the place where you administer deployments. This requires you to log in with your Windows Live ID. Figure 1 shows the login page.
When
logged in, you can choose what cloud services you want to administer
(for example Windows Azure, .NET Services, or SQL Azure) other than
seeing available projects, if any. Figure 2 shows this Welcome page.
Ensure that Windows Azure is selected on the left. Now click the New Service
link. This opens a new page where you can decide to create a new Hosted
Service (that enables deploying a Web application) or a new Storage
Account (which enables creating storages for blobs, tables, and
queues), as shown in Figure 3.
Click Hosted Services to
publish the sample application. In next page you need to type a label
and a description for the service. See Figure 4 for an example.
Click Next.
The subsequent step is really important because it is the place where
you can customize your application’s address on the Internet. Windows
Azure’s domain is http://CustomName.cloudapp.net, where CustomName is the name you provide for your application. In this example I’m using my name, so the complete application address will be alessandrodelsole.cloudapp.net. Replace my name with yours and check if the address is available with the Check Availability
button. You can then choose the data center location, such as northern
and southern regions in the United States. By the way, for this example
select Anywhere US, as shown in Figure 5.
Note
Due
to recent changes to the Windows Azure Service Platforms, the list of
available locations may vary including countries other than the United
States. Visit the Windows Azure official website (http://www.windowsazure.com) for detailed information.
When you click Create, the new
service is created and ready to receive the application deployment. The
deployment can be of two types: staging and production, as also
represented in Figure 6.
The
Staging deployment is intended for configuration and testing purposes.
After ensuring all works correctly, you can move the application to the
Production state. You could also directly deploy your application to
the Production state, but this is not always the best choice. Now click
the Deploy
button for the Staging deployment. On the next page you have to specify
the Application Package and the Configuration Settings. Both files are
stored in the Publish folder previously described. As an alternative
you can indicate files from an online Azure storage. The application
package is a file with .cspkg extension and contains all the required
application files in one package. The configuration file has .cscfg
extension and contains information on the web roles involved in your
application. Figure 7 shows how you indicate both files with regard to the current example.
Also specify a label for the current deployment. This is free text. At this point you can click the Deploy
button and wait until the deployment process is completed; this process
can last several minutes, so be patient. When the process is finished,
the application is not running yet. Click Run
to make your application run in the Staging deployment and wait until
the WebRole1 shows a green circle and the Ready word (see Figure 8).
There is a new link named Web
Site URL. This is a temporary address for your application that you can
use for your testing purposes. If you click it, the Web browser will
attempt to run the application in its staging state, but in this
particular example, you will see nothing. The reason is that,
obviously, the Web browser searches for the Default.aspx page that is
empty in our example because we created a new page for hosting a
Silverlight page. Append /BookStoreTestPage.Aspx to the web address.
After a few seconds, the sample application is correctly shown in the
Web browser, as demonstrated in Figure 9.
If you want to make your
Silverlight application start automatically, in Solution Explorer
remove the Default.aspx page and rename the test page for Silverlight
(in our example it is named BookStoreTestPage.Aspx) into Default.Aspx and set it as the start page.
|
Close the Web browser to return to the Azure administration page. If you want to edit the application configuration file, click Configure. This opens a new page showing the configuration file content within an editable text box. Click Suspend if you want to stop running the application keeping it in the cloud; instead click Upgrade
if you want to upload a new version of the application. At this point,
supposing all works correctly, we can move the application to the
production state, by simply clicking the rounded button at the center
of the page. After a few seconds the application is available on the
cloud, and it is reachable on the Internet (see Figure 10 for details).
Now you can finally run the application on the cloud. The sample application is, in this case, http://alessandrodelsole.cloudapp.net. To ensure the correct page is shown, the full address is http://alessandrodelsole.cloudapp.net/BookStoreTestPage.Aspx. Figure 11 shows the application running from the Windows Azure location.
With a few steps you
successfully published a Web application to Windows Azure making it
reachable from the Internet. If you plan on building data-centric
applications requiring SQL Server database, the suggestion is that you
visit the SQL Azure Developer Portal where you can find lots of
information about creating and consuming databases on the cloud. You
can find the portal here: http://msdn.microsoft.com/en-us/sqlserver/dataservices/default.aspx.