gpt4 book ai didi

azure - 如何以编程方式设置 Azure VM 角色实例就绪/忙碌?

转载 作者:行者123 更新时间:2023-12-04 18:21:36 27 4
gpt4 key购买 nike

有什么方法可以将虚拟机角色实例的状态从繁忙更改为就绪。如果可能的话,我想用 wcf 服务来做到这一点。非常感谢。

最佳答案

Fabric Controller 将定期检查实例的状态,这样做时您将能够让它知道实例是否繁忙。

您只需处理 StatusCheck 事件并将其设置为忙(通过调用 SetBusy 方法)。一旦您确定实例已准备好(不再繁忙),请停止调用 SetBusy 方法。

public override bool OnStart()
{
RoleEnvironment.StatusCheck += RoleEnvironmentStatusCheck;

return base.OnStart();
}

// Use the busy object to indicate that the status of the role instance must be Busy
private volatile bool busy = true;

private void RoleEnvironmentStatusCheck(object sender, RoleInstanceStatusCheckEventArgs e)
{
If (this.busy)
{
// Sets the status of the role instance to Busy for a short interval.
// If you want the role instance to remain busy, add code to
// continue to call the SetBusy method
e.SetBusy();
}
}

引用:http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.serviceruntime.roleenvironment.statuscheck.aspx

关于azure - 如何以编程方式设置 Azure VM 角色实例就绪/忙碌?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10550411/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com