I am a bit confused about deployment of cloud services, and particular whether just code can be replaced

StackOverflow https://stackoverflow.com/questions/22648913

  •  21-06-2023
  •  | 
  •  

Question

Just getting used to VS2012 publishing of Cloud Services. At present I have a one instance webrole which contains a MVC3 application. I can publish it to Azure without issue, and it creates the Cloud Service>Web Role>VMs. Fine. Takes a little while.

However when I do a little code change how can I migrate just this code change without replacing all the VMs that implement the WebRole etc.

It seems that Code and infrastructure are inseparable, or have I misunderstood. Is there a way to just update the code bit?

Thanks.

Était-ce utile?

La solution

When you roll out an update, you upload an entire package containing not only your code files, but also the configuration for the VM, such as # of instances, ports to open on the firewall, local resources to allocate, etc. These configuration settings are part of the code package - so there is more going on than just updating code files.

However, there are a couple of methods you can use to have more granular control over updates.

  1. Use Web Deploy. One thing to keep in mind, is that any automatic service updates will restore your website to the last fully-deployed package, which may not be as up-to-date. You would only want to use this in staging, then do a full package update for production rollout.
  2. Use an Azure Web Site instead, which allows continuous integration with your source control provider, and direct updates to the code.
  3. Use an Iaas VM instead. These are basically the same as running your own custom server in the Azure cloud, and you have full control over the OS. However, you also have full responsibility for keeping the OS updated and secure.
  4. You can also enable RDP to your Azure Web Role VM's. You will find all your code files there and IIS, but I wouldn't recommend updating your code this way for the same reasons listed in #1.

Autres conseils

The code and infrastructure, in a cloud service, are actually separate. All you upload is a deployment package containing just your code and supporting libraries / files. You don't upload a vhd. Azure provides that for you, spinning up a vhd, and then accessing your code on a file folder on that vhd. Same process happens each time you scale out to more instances.

when you make a code change, you build a new deployment package and deploy that. If you do it as an in-place update (vs delete+redeploy), each role is updated on each instance (when you have multiple instances of a role, they're not all updated at the same time). You can even specify that you only want a single role within the deployment to be updated (helpful if, say, you have a worker role in addition to your web role, and want to leave all the worker role instances running).

when the code update happens, the VMs aren't replaced, but they are recycled, and when they start back up, they are running the updated code.

You can use WebDeploy with Cloud Services in production across multiple servers using the AzureWebFarm project (disclaimer: I maintain it).

Alternatively, you can also use the excellent Octopus Deploy deployment technology in conjunction with the AzureWebFarm.OctopusDeploy project (disclaimer: I maintain this one too).

To be honest though, if you just have a simple web app then I wouldn't both with cloud services - I'd just use Web Sites. Feel free to check out my blog post to see the situations which might force you to use cloud services though.

If you enable WebDeploy on the cloud service, you can use web deploy to publish the MVC application.

See http://msdn.microsoft.com/en-us/library/windowsazure/ff683672.aspx for details.

All of the above answers are correct and if you are trying to change your code for a production service you definitely want to do an in place upgrade as described. However, frequently during the dev/test phase or troubleshooting I want to make one small change and test it out quickly. To do this check out http://blogs.msdn.com/b/kwill/archive/2013/09/05/how-to-modify-a-running-azure-service.aspx which describes how to modify the code via RDP to the Azure VM.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top