[英]Azure Cloud Service - Monitoring a deployment
网站发布和更新后是否引发了事件?
我已经在global.asax中尝试过Application_End,但是似乎未引发该事件。
我建议同时使用Kudu和Microsoft ASP.NET WebHooks预览。
Kudu是git部署,WebJobs和Azure网站中各种其他功能的引擎(Kudu来源在GitHub上)
使用Kudu,Azure网站支持Web挂钩。 每当部署完成并产生部署结果时,都会调用事件“ PostDeployment”。
Microsoft ASP.NET WebHooks预览提供了一种通用模型,用于从任何数量的WebHook提供程序接收和处理WebHooks,包括对Kudu(Azure Web App部署)的支持。
因此,您可以使用Kudu WebHooks在部署更新时得到通知。 (但这将需要使用Git Deploy而不是其他方式来发布您的网站)。
这是这样做的方法:首先安装Microsoft.AspNet.WebHooks.Receivers.Azure Nuget程序包。 将这两行添加到WebApiConfig.Register方法中:
config.InitializeReceiveKuduWebHooks();
config.InitializeReceiveAzureAlertWebHooks();
然后添加一个处理程序:
public class KuduWebHookHandler : WebHookHandler
{
public KuduWebHookHandler()
{
Receiver = "kudu";
}
public override Task ExecuteAsync(string generator, WebHookHandlerContext context)
{
// Convert to POCO type
KuduNotification notification = context.GetDataOrDefault<KuduNotification>();
// Get the notification message
string message = notification.Message;
// Get the notification author
string author = notification.Author;
return Task.FromResult(true);
}
}
然后配置一个秘密,该秘密可以验证WebHook请求确实来自Kudu。 使用高熵值,例如SHA256哈希或类似值,您可以从http://www.freeformatter.com/hmac-generator.html获得。 另外,通过Azure门户设置它们,而不是在Web.config文件中对其进行硬编码。另外,通过Azure门户设置它们,而不是在Web.config文件中对其进行硬编码。
有关此主题的文章,更完整( http://blogs.msdn.com/b/webdev/archive/2015/10/04/receive-webhooks-from-azure-alerts-and-kudu-azure-web -app-deployment.aspx )
希望这对您有所帮助Stéphane
我想到了。 在Application_Start事件中,我绑定
RoleEnvironment.Stopping += RoleEnvironmentStopping;
private void RoleEnvironmentStopping(object sender, RoleEnvironmentStoppingEventArgs e)
{
// do something ...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.