Avkash Chauhan's Blog

Windows Azure, Windows 8, Cloud Computing, Big Data and Hadoop: All together at one place.. One problem, One solution at One time...

How to perform custom IIS configuration such as Adding Dynamic Compression for additional mime types in Web Role using Startup Task

How to perform custom IIS configuration such as Adding Dynamic Compression for additional mime types in Web Role using Startup Task

Rate This
  • Comments 2

As you may know, you can use appcmd.exe application to configure IIS and when you are using Web Role in your Azure Application, it is possible that you may need to configure IIS before the role starts. You can use startup task method to launch appcmd.exe to perform such configuration. To learn more about Windows Azure startup task click here..

 

For example we want to add dynamic compression for “Application/soap+xml” MIME type and static compression for “text/xml” MIME type.  Here are the detailed steps to configure these settings using AppCmd process:

 

1. Create a folder name Startup in your Project

2. Create a command batch file name launchappcmd.cmd in the same folder and add following command:

 

appcmd set config /section:httpCompression /+staticTypes.[mimeType='text/xml',enabled='true'] /commit:apphost
appcmd set config /section:httpCompression /+dynamicTypes.[mimeType='application/soap+xml’,enabled='true'] /commit:apphost

 

At this point your VS2010 based application will look like as below:

 

3. Now add the following code in your Service Definition (ServiceDefinition.csdef):

 

<Startup>
   <Task commandLine="Startup\LaunchAppCmd.cmd" executionContext="elevated" taskType="simple">
   </Task>
</Startup>

 

 

That’s it!! Now you can verify that IIS configuration file has above configuration settings, by RDP to your Azure VM.

Leave a Comment
  • Please add 3 and 2 and type the answer here:
  • Post
  • Hi Avkash,

    It is important to remember to set the "LaunchAppCmd.cmd" "Copy to output Directory" property to "always", otherwise the file will not be part of the package.

    Tal

  • What would the command look like if you have multiple static mimetypes?

    Thanks!

Page 1 of 1 (2 items)