我在Azure的App Service平台上构建名为fooapp
的Web应用程序,并配置为具有名为slot1
的插槽
目前,我正以编程方式将名为slot1
的插槽交换到我的实际网络应用程序,名为fooapp
,通过Azure's ARM API使用C#编写的HTTP客户端。可以使用Resource Explorer探索可能的端点。
这有效,但交换本身大约需要1-2分钟,因此我想在交换完成后通过电子邮件通知自己。是否有一个端点来调用交换状态?
以下代码使HTTP Json帖子在C#中与slot1
交换fooapp
。
var httpClient = new HttpClient();
var uri = "https://management.azure.com/subscriptions/{mysubscriptionid}/resourceGroups/{myresourcegroup}/providers/Microsoft.Web/sites/fooapp/slots/slot1/slotsswap?api-version=2015-08-01";
var response = httpClient.PostAsJsonAsync(uri, new { targetSlot = "production" });
任何人的想法?我曾尝试过寻找文件,但随着Azure提供的不断扩展的功能,它的沙漠干燥
答案 0 :(得分:1)
您可以使用活动日志API来跟踪广告位交换的状态。以下是REST API的简单示例调用。
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/{mysubscriptionid}/providers/microsoft.insights/eventtypes/management/values?api-version=2015-04-01&$filter=eventTimestamp ge '2016-09-08T01:53:03.0422573Z' and eventTimestamp le '2016-09-08T02:53:03.0422573Z' and resourceUri eq '/subscriptions/{mysubscriptionid}/resourcegroups/{myresourcegroup}/providers/Microsoft.Web/sites/fooapp/slots/slot1'&select=Authorization,Caller,CorrelationId,Category,EventTimestamp,OperationName,ResourceGroupName,ResourceUri,Status,SubscriptionId,SubStatus
对于这个REST API,您需要注意一些事项。
eventTimestamp ge '2016-09-08T01:53:03.0422573Z'
,设置" eventTimestamp"大于或等于调用插槽之前的时间戳。eventTimestamp le '2016-09-08T02:53:03.0422573Z'
。你应该设置" eventTimestamp"小于或等于当前时间戳。您将获得3个可能的日志,表明您的插槽交换成功。
第一个,"开始"。
Authorization :
Scope : /subscriptions/{mysubscriptionid}/resourcegroups/{myresourcegroup}/providers/Microsoft.Web/sites/fooapp/slots/slot1
Action : Microsoft.Web/sites/slots/slotsswap/action
Role :
Condition :
Caller : <your Azure account>
CorrelationId : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Category : Administrative
EventTimestamp : 2016-09-08 2:48:39 AM
OperationName : Microsoft.Web/sites/slots/slotsswap/action
ResourceGroupName : {myresourcegroup}
ResourceId :
Status : Started
SubscriptionId : {mysubscriptionid}
SubStatus :
第二个,&#34;接受&#34;。
Authorization :
Scope : /subscriptions/{mysubscriptionid}/resourcegroups/{myresourcegroup}/providers/Microsoft.Web/sites/fooapp/slots/slot1
Action : Microsoft.Web/sites/slots/slotsswap/action
Role :
Condition :
Caller : <your Azure account>
CorrelationId : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Category : Administrative
EventTimestamp : 2016-09-08 2:48:41 AM
OperationName : Microsoft.Web/sites/slots/slotsswap/action
ResourceGroupName : {myresourcegroup}
ResourceId :
Status : Accepted
SubscriptionId : {mysubscriptionid}
SubStatus : Accepted
第三个,&#34;成功&#34;。
Authorization :
Scope : /subscriptions/{mysubscriptionid}/resourcegroups/{myresourcegroup}/providers/Microsoft.Web/sites/fooapp/slots/slot1
Action : Microsoft.Web/sites/slots/write
Role :
Condition :
Caller : <your Azure account>
CorrelationId : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Category : Administrative
EventTimestamp : 2016-09-08 2:49:44 AM
OperationName : Microsoft.Web/sites/slots/write
ResourceGroupName : {myresourcegroup}
ResourceId :
Status : Succeeded
SubscriptionId : {mysubscriptionid}
SubStatus :
如果您正在使用服务主体,那么&#34;来电者&#34;在输出中可能会有所不同。如果插槽交换失败,您将收到&#34;失败&#34;对于第二个或第三个日志。