2

I have an Azure web app that uses a startup task batch file (addtask.cmd) to install a small heartbeat utility into the scheduler.

If I'm testing locally or in the Azure staging environment, I dont want to install the heartbeat utility.

How can I prevent the startup task, or the batch file, from running in those environments?

I can probably detect local environment by checking for my machine name, but how would you detect running in the staging environment?

PeteShack
  • 707
  • 1
  • 8
  • 20
  • Short version you can't and you shouldn't. This is a duplicate of this question: http://stackoverflow.com/questions/4328462/staging-or-production-instance i.e – knightpfhor Jun 03 '11 at 04:37
  • Note that Igorek does actually include an answer at the bottom of his answer to the question knightpfhor refers to. Detecting dev fabric is a duplicate of http://stackoverflow.com/questions/2915340/how-to-detect-that-azure-application-is-running-in-development-fabric – Oliver Bock Jun 03 '11 at 05:28

1 Answers1

1

I don't have an answer for the staging vs. production slots in the cloud, but if you want to avoid executing Startup Tasks when in a development environment, there is a very simple technique I have been using for a while - and use constantly.

The trick: set an environment variable on your dev machine and using basic DOS batch file (or PowerShell) techniques, jump over the stuff you don't want if that variable is present. It will not be present in the cloud.

I blogged about it here: Azure FAQ: Can I create a Startup Task that executes only when really in the Cloud?

codingoutloud
  • 2,115
  • 19
  • 21