gpt4 book ai didi

azure - WebDeploy 到 Azure 失败

转载 作者:行者123 更新时间:2023-12-03 06:02:57 26 4
gpt4 key购买 nike

我使用以下代码通过 WebDeploy 部署到 Azure 网站。我可以使用相同的服务器和凭据信息通过 Visual Studio 2013 的 WebDeploy 部署到同一站点,但是当我运行下面的代码时,它不断失败并告诉我它无法授权,它收到 401。任何想法?

var sourceBaseOptions = new DeploymentBaseOptions();
DeploymentBaseOptions destBaseOptions = new DeploymentBaseOptions()
{
UserName = prf.UserName,
Password = prf.UserPassword,
ComputerName = string.Format("https://{0}/MsDeploy.axd?Site={1}",
prf.PublishUrl,
prf.MSDeploySite)
};
//-disableLink:AppPoolExtension
//-disableLink:ContentExtension
//-disableLink:CertificateExtension
foreach (var extension in sourceBaseOptions.LinkExtensions
.Where(ext => ext.Name == "AppPoolExtension"
|| ext.Name == "ContentExtension"
|| ext.Name == "CertificateExtension"))
{
extension.Enabled = false;
}
sourceBaseOptions.Trace += sourceBaseOptions_Trace;
sourceBaseOptions.TraceLevel = System.Diagnostics.TraceLevel.Verbose;
foreach (var extension in destBaseOptions.LinkExtensions
.Where(ext => ext.Name == "AppPoolExtension"
|| ext.Name == "ContentExtension"
|| ext.Name == "CertificateExtension"))
{
extension.Enabled = false;
}

using (var deploymentObject = DeploymentManager.CreateObject(
DeploymentWellKnownProvider.Package,
@"E:\DeployPackages\Site.zip",
sourceBaseOptions))
{
//configure deploy target Web site name instead of using -SetParams
deploymentObject.SyncParameters
.Single(p => p.Name == "IIS Web Application Name")
.Value = prf.MSDeploySite;

DeploymentSyncOptions syncOptions = new DeploymentSyncOptions();
syncOptions.WhatIf = false;

// Will fail on this call
var changes = deploymentObject.SyncTo(DeploymentWellKnownProvider.Auto,
"",
destBaseOptions,
syncOptions);

}

最佳答案

当然,在我发布这篇文章后不到一分钟,我就灵光一现...修复方法只是将 AuthenticationType = "Basic"设置为 destBaseOptions 对象。

现在感觉自己像个骨头……

关于azure - WebDeploy 到 Azure 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23147330/

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