以编程方式启动 Azure 网站插槽
Programmatically start an Azure website slot
我正在尝试使用 C# 代码序列以编程方式为 Azure 网站启动一个插槽。
我尝试使用以下代码:
public async Task StartWebsiteSlot()
{
var subscriptionId = "{my Azure subscription id}";
var certPath = "{my full path to the Azure management certificate}";
var certificate = new X509Certificate2( certPath, {my password});
var httpHandler = new WebRequestHandler();
httpHandler.ClientCertificates.Add(certificate);
httpHandler.ClientCertificateOptions = ClientCertificateOption.Automatic;
var url = "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{groupname}/providers/Microsoft.Web/sites/{site name}/start?api-version=2015-08-01";
var postContent = new StringContent( String.Empty );
using (var client = new HttpClient(httpHandler))
{
var response = await client.PostAsync(url, postContent);
}
}
通话returns"Unathorized"。
我知道证书没问题,因为我将它与 WebManagementClient 一起使用来交换部署槽。
我应该如何访问特定的 Azure 管理 REST API?
this Nuget package lets you manage the websites from C#. Once you get the nuget package loaded, you can use the RestartAsync()方法启动网站。用法见下。
yourwebsiteclient.Websites.RestartAsync
希望对您有所帮助!
https://www.nuget.org/packages/Microsoft.WindowsAzure.Management.WebSites/
看看这个问题:
Change Azure website app settings from code.
它使用了 neolursa 建议的 Azure 管理库。
棘手的部分是配置 SSL:Using Azure Management Libraries from Azure Web Jobs
David Ebbo 在 https://github.com/davidebbo/AzureWebsitesSamples/ 上提供了解决方案
必须用 StartSiteAsync 或 StartSiteSlotAsync 替换 RestartAsync 调用。
我正在尝试使用 C# 代码序列以编程方式为 Azure 网站启动一个插槽。 我尝试使用以下代码:
public async Task StartWebsiteSlot()
{
var subscriptionId = "{my Azure subscription id}";
var certPath = "{my full path to the Azure management certificate}";
var certificate = new X509Certificate2( certPath, {my password});
var httpHandler = new WebRequestHandler();
httpHandler.ClientCertificates.Add(certificate);
httpHandler.ClientCertificateOptions = ClientCertificateOption.Automatic;
var url = "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{groupname}/providers/Microsoft.Web/sites/{site name}/start?api-version=2015-08-01";
var postContent = new StringContent( String.Empty );
using (var client = new HttpClient(httpHandler))
{
var response = await client.PostAsync(url, postContent);
}
}
通话returns"Unathorized"。 我知道证书没问题,因为我将它与 WebManagementClient 一起使用来交换部署槽。
我应该如何访问特定的 Azure 管理 REST API?
this Nuget package lets you manage the websites from C#. Once you get the nuget package loaded, you can use the RestartAsync()方法启动网站。用法见下。
yourwebsiteclient.Websites.RestartAsync
希望对您有所帮助!
https://www.nuget.org/packages/Microsoft.WindowsAzure.Management.WebSites/
看看这个问题: Change Azure website app settings from code.
它使用了 neolursa 建议的 Azure 管理库。
棘手的部分是配置 SSL:Using Azure Management Libraries from Azure Web Jobs
David Ebbo 在 https://github.com/davidebbo/AzureWebsitesSamples/ 上提供了解决方案 必须用 StartSiteAsync 或 StartSiteSlotAsync 替换 RestartAsync 调用。