0
我正在使用下面的代碼通過WebDeploy部署到Azure網站。我可以使用相同的服務器和憑證信息,通過Visual Studio 2013部署到WebDeploy的同一站點,但是當我運行下面的代碼時,它會一直失敗,並告訴我它無法授權,它會得到一個401.任何想法?WebDeploy到Azure失敗
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);
}