Scott Decker
Scott Decker

Reputation: 4307

Deploy to Azure without starting roles

We have an app we deploy to Azure. It involves deploying several cloud services with a mix of web roles and worker roles. Some of the worker roles pick items up off a queue and process them. We also have some scheduled jobs that run periodically (backing up Azure table storage, etc).

Every time we deploy, we have to watch the Staging environment in the portal and manually stop the roles from starting. We have to do this because we don't want the Staging and Production slots both processing information at the same time (e.g. pulling from the same queue but processing it differently, or both running the same scheduled job simultaneously, etc).

The only way I've found to have a deployment go into Staging in a stopped state is to leave the last deployment there also stopped. Downside is you're charged for those instances, even when they're not running.

So, how do you deploy to an empty staging slot in Azure without the deployment starting up?

EDIT: We kick off the builds through Visual Studio or Visual Studio Online (i.e. TFS). Don't usually use powershell.

Upvotes: 2

Views: 576

Answers (2)

kwill
kwill

Reputation: 11008

There is no way to create a deployment but not have it start. What you can do instead is have a setting in your csdef/cscfg that your code would read during OnStart.

For example, you would have a setting called "ShouldRun" set to False. In OnStart you would have a loop that checked that setting and exits the loop if ShouldRun==True. After you deploy you would then go to the portal and change that setting to True whenever you are ready for it to start processing. Once the loop exits then the OnStart method will finish which will cause Azure to call your Run method and bring your instances to the Ready state.

In addition you could add a Changed event handler to stop processing messages when the setting was changed to False. This would let you first stop your production deployment and then start your staging deployment.

Upvotes: 1

Thiago Custodio
Thiago Custodio

Reputation: 18362

For me, you need to separate even your queue's and configs. Another option, you can create a powershell script to stop your cloud service after publish to it.

http://msdn.microsoft.com/en-us/library/dn495211.aspx

Upvotes: 0

Related Questions