How to stop a single instance / WebRole / WorkerRole virtual machine

We have a VM that says that SampleVM is deposited and works in an Azure environment, and on the same we created 2 instances. One of them is WebRole, and the other is WorkerRole, which runs at the Slot stage.

My problem: I can start / stop SampleVM using the powershell command, but how can I start / stop one instance (WebRole or WorkerRole) running on SampleVM.

However, when I stop SampleVM, both instances also stop, but I want to stop only one instance / VM, i.e. WebRole or WorkerRole.

Provide powershell command with pass argument to stop / start one instance

+6
source share
3 answers

A good answer from Gaurav, but I wanted to add a little more detail, since I think there might be a bit of confusion around web and work roles. Each role is a definition for a group of virtual machines that do the same thing that you built (you do not deal with the OS - you just run your application, and Azure takes care of the virtual machine itself).

When the cloud service is running, there will be at least one instance of each type of role. Thus, in your case, working as a web role role and a working role, you will have at least two virtual machines.

If you decide to reduce your web role to, say, 3 copies, and then decide to dial it up to 2 copies, you will not be able to choose which one to disable; it takes care of the azure fabric. Remember that each role instance has the same code, and Azure balances traffic with your role instances (through the external endpoints that you define). The only thing you need to worry about is shutting down. You have approx. 5 minutes to clear all running processes (and you can easily extract a specific instance from load balancing during shutdown, since you received the Stopping() event).

You cannot close the entire role (for example, all role instances) in the cloud service (so ... you cannot delete instances of the worker role, leaving instances of the web role). If this is a requirement, then you can always consider launching your web role in one cloud service and a working role in another cloud service. If they use queues for data transfer, everything will work as before. If web role instances need direct access to worker role instances, you can put both cloud services on a virtual network.

Another thing to consider: you do not need to have separate roles. If cost is a factor, you can run all of your code in your web role. Does a little work to deploy additional processes / threads in your web role, during OnStart() - remember that role instances are full Windows Server virtual machines; run whatever you want. With one definition of a role, scaling is a bit crude: everything scales together. With individual roles, you can fine-tune the scaling (which is much more important when building larger systems).

+6
source

David points out in more detail how to model your PaaS service. But to add to it, a new service management API has appeared that has just been released under the name "Delete Role Instance", which will allow you to delete a specific instance of the role - http://msdn.microsoft.com/en-us/library/windowsazure /dn469418.aspx . This functionality is completely new, so you can choose which instance to delete, rather than obeying the standard behavior described by David (always deleting the last instance).

+4
source

The simple answer is that from today you cannot stop one instance of the role of your web / worker. When you stop the role, all instances stop. You can remove instances from your role, but again you cannot specify which particular instance you want to delete. See below @kwill.

You can also find the following links useful for removing specific role instances:

http://gauravmantri.com/2013/10/16/a-new-version-of-windows-azure-service-management-api-is-available-with-delete-specific-role-instances-and-more- goodies /

https://github.com/richorama/Two10.Azure.SelfDestruct

+3
source

Source: https://habr.com/ru/post/955971/


All Articles