October 25, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

How To Configure Settings for a Windows Azure Application

  • May 12, 2011
  • By Vipul Patel
  • Send Email »
  • More Articles »

Introduction

Azure developers have a few options to configure their cloud-based applications. These settings come in form of configuration files which are packaged and deployed along with your application.

For developers, it is important to understand these settings.

Types of Windows Azure Configuration Files

Inside your Windows Azure application are two special files which are used for configuring settings of your Windows Azure application.

Figure 1

To see these configuration files, open up an existing Azure project or create a new Azure application.

Make sure to select a couple of roles for your application.

After the application is created, you can see the configuration files in the Solution Explorer.

Figure 2

Let's examine these files in more detail.

The ServiceDefinition.csdef File

The ServiceDefinition.csdef file contains the information about the application itself, including the roles the application contains. For example, we can see in the file contents below that the Windows Azure application we created contains both the Web role as well as Worker Role.

<?xml version="1.0" encoding="utf-8"?>

<ServiceDefinition name="WindowsAzureProjectConfigurationExample" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">

<WebRole name="WebRole1">

<Sites>

<Site name="Web">

<Bindings>

<Binding name="Endpoint1" endpointName="Endpoint1" />

</Bindings>

</Site>

</Sites>

<Endpoints>

<InputEndpoint name="Endpoint1" protocol="http" port="80" />

</Endpoints>

<Imports>

<Import moduleName="Diagnostics" />

</Imports>

</WebRole>

<WorkerRole name="WorkerRole1">

<Imports>

<Import moduleName="Diagnostics" />

</Imports>

</WorkerRole>

</ServiceDefinition>

These settings are:

  • Read at runtime by Windows Azure Service hosting runtime API.

  • Cannot be changed while the service is running. The Windows Azure service will have to be redeployed.

The ServiceConfiguration.cscfg File

The ServiceConfiguration.cscfg file contains values for the settings defined in the ServiceDefinition.csdef file. This file also contains the number of instances of the defined roles.

The service configuration file can be changed while the service is running (unlike the ServiceDefinition.csdef file).

<?xml version="1.0" encoding="utf-8"?>

<ServiceConfiguration serviceName="WindowsAzureProjectConfigurationExample" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*">

<Role name="WebRole1">

<Instances count="1" />

<ConfigurationSettings>

<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />

</ConfigurationSettings>

</Role>

<Role name="WorkerRole1">

<Instances count="1" />

<ConfigurationSettings>

<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />

</ConfigurationSettings>

</Role>

</ServiceConfiguration>

The properties can be changed by right-clicking the “Role” in the Solution Explorer and selecting Properties

Figure 3

Figure 4

Let's change the number of WebRoles to 4 in the Properties Window above. Now, when we open the ServiceConfiguration.cscfg, we see the following change.

<?xml version="1.0" encoding="utf-8"?>

<ServiceConfiguration serviceName="WindowsAzureProjectConfigurationExample" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*">

<Role name="WebRole1">

<Instances count="4" />

<ConfigurationSettings>

<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />

</ConfigurationSettings>

</Role>

<Role name="WorkerRole1">

<Instances count="1" />

<ConfigurationSettings>

<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />

</ConfigurationSettings>

</Role>

</ServiceConfiguration>

Understanding the Available Azure Settings

Property

Description

.NET Trust level

The roles by default have full trust. However, when native execution is required, the setting should be set to Windows Azure Partial Trust.

Instances

You can set this to the number of instances you desire for the roles.

Startup action

This is applicable for the web role only. This describes how VS launches the browser for either HTTP/HTTPS endpoints, or both.

Diagnostics

You can enable/disable diagnostic logging. If you enable, you can choose to log to your Windows Azure storage account.

EndPoints

You can provide HTTP/HTTPS endpoints. For HTTPS endpoints, you will need a management certificate.

Local Storage

You can specify a reserved directory in the file system of your Windows Azure virtual machine as a local storage resource.

Certificates

Here, one can specify the certificates associated with your role.

Virtual Network

One can associate a Windows Azure Connect token with a role. The token has to be activated using the Windows Azure Management portal.

Summary

In this article, we saw the various configuration settings that are available in a Windows Azure application. Hopefully, you have found this information useful and will be able to write better cloud applications.

About the author

Vipul Patel is a Software Engineer currently working at Microsoft Corporation. He is currently working in the Office Communications Group and has worked in the .NET team earlier in the Base Class libraries and the Debugging and Profiling team. He can be reached at vipul_d_patel@hotmail.com


Tags: tutorial, app development, Microsoft Windows Azure, Windows Azure Applications, Azure Configuration

Originally published on http://www.developer.com.


Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel