Home > Sample chapters > Programming > Windows

Azure Websites and Azure Cloud Services

Deploying and monitoring websites

In this section, we look at options for creating website content, show how to publish your website from Visual Studio 2013, and look at the monitoring options in the Azure Management Portal.

Options for creating websites

There are multiple options for creating a website and pushing the content up to Azure Websites.

Notepad or an HTML editor

This is a pretty limited way to create a website, but if you’re beginning on your journey to learn web development and want to create a simple HTML page, you can do that with Notepad or your favorite HTML editing tool. After you’re done, you can FTP to the website and transfer the files.

To FTP your files up to your website, log into the Azure Management Portal, click Websites, and then select your website. If you have not set up your login credentials yet, click Reset Your Deployment Credentials in the “quick glance” column. When prompted, provide a username and password. This is for access via Git or FTP.

Also under the “quick glance” column, the FTP HOST NAME and the DEPLOYMENT / FTP USER are provided. When you FTP in to your website, you will use these two pieces of information in addition to the password to access your website and place your files.

WebMatrix

This is a free, lightweight, cloud-connected web development tool that will enable you to create, publish, and maintain your websites. You can download this from http://www.microsoft.com/web/webmatrix/. Here are some of the features of this application:

  • Seamless integration with Azure Websites.
  • Can be used with PHP, Node.js, ASP.NET, HTML5, CSS3, and jQuery.
  • Enables you to support many of the websites in the Website Gallery in the Azure Management Portal or the Website Marketplace in the Azure Preview Portal. Some examples of the websites available are Umbraco, WordPress, Joomla!, and Drupal.
  • Allows management for SQL Server, SQL CE, and MySQL databases.
  • Works seamlessly with Git and TFS.
  • Can be used to develop websites locally or remotely using FTP or WebDeploy.

You can log in using the Microsoft account you use for Azure, create a new web application using one of the templates available, and publish it. When you log into either of the Azure Management Portals, you will see your new web application. You can make changes, verify the results in the local browser, and then republish. Republishing only deploys the modified files.

Visual Studio

Visual Studio is a full development environment, giving you the ability to create many different kinds of applications including, but not limited to, ASP.NET MVC applications, .NET client applications, Windows Communication Foundation (WCF) services, Web API, and Cloud Services, using languages such as C#, C++, VB, F#, and XAML.

With Visual Studio, you can create a new web application and publish it directly to Azure Websites. We’ll see how to do this in the next section.

Publishing a website from Visual Studio

Open one of your web applications in Visual Studio. If you don’t have a web application yet, create a new one with Visual Studio by selecting FILE > NEW PROJECT, selecting an ASP.NET Web Application, specifying the folder for the solution, and then selecting MVC Application. This gives you a basic MVC application that runs “as is.” You can modify it later to make it your own.

Let’s publish the web application to the Azure website we created earlier in this chapter.

  1. Open your web application in Visual Studio. Right-click the website and select Publish Web Site.

    p0063_01.jpg

    The Publish Web dialog will be displayed.

    p0063_02.jpg
  2. Select Windows Azure Web Sites. You will be asked to sign into your Azure account.
  3. After signing in, you will be prompted to select the website to which to deploy. Select your website in the drop-down list and click OK. It retrieves the publishing settings from Azure and displays the connection information.

    p0064_01.jpg
  4. Click Validate Connection to make sure the connection works.

  5. Click Next to go to the next screen, where you can select Debug or Release Configuration. Accept the defaults on that screen and click Next to go to the final screen.
  6. On the final screen, you can preview the files that will be published. Click Publish to publish the website. All of the files will be deployed to the website, and then it will open the website.

When you make changes to your website and go through this same process to publish the website again, it will only publish the files that have been added or modified.

Monitoring a website

You can set up many metrics to be monitored for a website. To do this, log into the Azure Management Portal (manage.windowsazure.com), select WEBSITES, and then select your website. When it brings up the Quick Start or the DASHBOARD, select MONITOR from the options at the top of the screen.

Initially, you will see only six metrics: CPU Time, Data In, Data Out, Http Server Errors, and Requests. If you set up Endpoint Monitoring on the CONFIGURE screen, you also will see the response times here (Figure 2-19).

FIGURE 2-19

FIGURE 2-19 Monitoring a website.

You can see the endpoints defined earlier for Hong Kong, Dublin, and San Jose, CA. You can request as many metrics as you need to be displayed in the list, but you can select only six metrics to appear on the chart at any given time. You can add metrics by clicking +ADD METRICS at the bottom of the screen. There are several more that can be selected.

The time frame displayed is 1 HOUR, as selected in the upper-right corner. Note that there is no y-axis. This is because each metric has its own y-axis value; it charts these to make the best of the space available.

There are other monitoring applications available through the Azure Store in the Azure Management Portal, including New Relic and App Dynamics. These can be selected and configured on the CONFIGURE screen in the Developer Analytics section.