2

I have these lines in my ServiceDefinition file in an Azure project:

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

But for test server and production server it has to be different Reminder.cmd files. How do I do it? I know that we can have a different configuration for ServiceConfiguration, but can't figure out how to have a different configuration for ServiceDefinition file.

w5m
  • 2,286
  • 3
  • 34
  • 46
Sergey
  • 7,933
  • 16
  • 49
  • 77

2 Answers2

2

Unfortunately, there is no way to configure your ServiceDefinition file to do this for Startup Tasks running in a deployed environment. The general advice around this is to put custom code/tests in the task itself to exit if it is not running in your production server.

However, you can configure the Startup Task to not run on your local development machine in the ServiceDefinition. Steve Marx has a nice post on how to do that.

<Startup>
  <Task executionContext="elevated" commandLine="startup\startup.cmd">
    <Environment>
      <Variable name="EMULATED">
        <RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />
      </Variable>
    </Environment>
  </Task>
</Startup>
Robert Greiner
  • 29,049
  • 9
  • 65
  • 85
  • Thanks I've got your idea and create the pre-build script to regenerate configuration file. – Sergey Jan 21 '13 at 21:05
0

The easiest way I know of is to have a different CSDEF file for each environment. The answers to this question will tell you how to do it.

That question was about changing VM sizes, but it's really the same problem. In your case you would just change the startup task for each environment.

Community
  • 1
  • 1
Brian Reischl
  • 7,216
  • 2
  • 35
  • 46