Remove msshrtmi.dll as a dependency in your Azure project

Msshrtmi.dll is a nasty little assembly that ships as part of the Azure SDK and is required as a dependency of ServiceRuntime to determine if you are running in or outside of Azure.

The problem lies in the fact that the assembly is unmanaged, and ships with different DLLs for x86 and x64. This causes all kinds of havoc as you need to build your projects with different target architectures depending upon context. As an example, IISExpress only runs in 32-bit mode.

Note: some of this pain is self-inflicted, as I absolutely refuse to install things into the GAC of my build server. This is a different post.

In order to remove this dependency, you need to find a different way of determining if you’re on Azure. We found the simplest way was to add an environment variable that was set as an Azure start-up task. We then look for this variable when constructing our RoleEnvironment adapter.

Add a batch file such as this to your project and set to copy always.

SetEnvVar.cmd

setx INAZURE True /M

Add the following element to the top of each WorkerRole element in your csdef files.

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

Update: Check out http://github.com/awithy/AzureCmdLetDeployment for a working example project.

Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: