我在 Azure Web 应用上部署包时遇到错误。
该应用程序是一个 .NET Web 应用程序,针对 4.0 框架编译。
这是我用于创建包的命令行:
"msdeploy.exe" -verb:sync -source:dirpath="C:\Users\Pierre\Documents\Projets\MyProject\MyApp" -dest:package=C:\Users\Pierre\Documents\MyProject\AzureResourceGroup\MyApp.zip
然后,在使用 azure 资源组模板进行部署时,出现以下错误
<?xml version="1.0" encoding="utf-8"?>
<entries>
<entry time="2016-01-06T09:55:20.4679645+00:00" type="Message">
<message>Downloading metadata for package path 'artifacts/MyApp.zip' from blob 'https://ccfstoragee57wqq4suhjoy.blob.core.windows.net'</message>
</entry>
<entry time="2016-01-06T09:55:20.5148382+00:00" type="Message">
<message>The blob has flag IsPremiumApp:. IsPremiumApp returns False</message>
</entry>
<entry time="2016-01-06T09:55:20.5617164Z" type="Message">
<message>Downloading package path 'artifacts/MyApp.zip' from blob 'https://ccfstoragee57wqq4suhjoy.blob.core.windows.net'</message>
</entry>
<entry time="2016-01-06T09:55:30.6280976Z" type="Message">
<message>No parameters were populated.</message>
</entry>
<entry time="2016-01-06T09:55:30.6280976Z" type="Message">
<message>Calling SyncTo() on package.</message>
</entry>
<entry time="2016-01-06T09:55:30.6280976Z" type="Message">
<message>Adding MSDeploy.dirPath (MSDeploy.dirPath).</message>
</entry>
<entry time="2016-01-06T09:55:30.6280976Z" type="Message">
<message>Adding MSDeploy.dirPath (MSDeploy.dirPath).</message>
</entry>
<entry time="2016-01-06T09:55:30.6280976Z" type="Message">
<message>Adding directory (C:\Users\Pierre\Documents\Projets\MyProject\MyApp).</message>
</entry>
<entry time="2016-01-06T09:55:30.6280976Z" type="Message">
<message>Adding directory (C:\Users\Pierre\Documents\Projets\MyProject\MyApp).</message>
</entry>
<entry time="2016-01-06T09:55:30.6593714Z" type="Error">
<message>Package deployment failed</message>
</entry>
<entry time="2016-01-06T09:55:30.7267862Z" type="Error">
<message>AppGallery Deploy Failed: 'Microsoft.Web.Deployment.DeploymentDetailedUnauthorizedAccessException: Unable to perform the operation ("Create Directory") for the specified directory ("C:\Users\Pierre\Documents\Projets\MyProject\MyApp"). This can occur if the server administrator has not authorized this operation for the user credentials you are using. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_INSUFFICIENT_ACCESS_TO_SITE_FOLDER. ---> Microsoft.Web.Deployment.DeploymentException: The error code was 0x80070005. ---> System.UnauthorizedAccessException: Access to the path 'C:\Users' is denied.
at Microsoft.Web.Deployment.NativeMethods.RaiseIOExceptionFromErrorCode(Win32ErrorCode errorCode, String maybeFullPath)
at Microsoft.Web.Deployment.DirectoryEx.CreateDirectory(String path)
at Microsoft.Web.Deployment.DirPathProviderBase.CreateDirectory(String fullPath, DeploymentObject source)
at Microsoft.Web.Deployment.DirPathProviderBase.Add(DeploymentObject source, Boolean whatIf)
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at Microsoft.Web.Deployment.FilePathProviderBase.HandleKnownRetryableExceptions(DeploymentBaseContext baseContext, Int32[] errorsToIgnore, Exception e, String path, String operation)
at Microsoft.Web.Deployment.DirPathProviderBase.Add(DeploymentObject source, Boolean whatIf)
at Microsoft.Web.Deployment.DeploymentObject.Add(DeploymentObject source, DeploymentSyncContext syncContext)
at Microsoft.Web.Deployment.DeploymentSyncContext.HandleAdd(DeploymentObject destObject, DeploymentObject sourceObject)
at Microsoft.Web.Deployment.DeploymentSyncContext.HandleUpdate(DeploymentObject destObject, DeploymentObject sourceObject)
at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject dest, DeploymentObject source)
at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildren(DeploymentObject dest, DeploymentObject source)
at Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject destinationObject, DeploymentObject sourceObject)
at Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable, Nullable`1 syncPassId, String syncSessionId)
at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)
at Microsoft.Web.Deployment.DeploymentObject.SyncTo(String provider, String path, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)
at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentWellKnownProvider provider, String path, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)
at Microsoft.Web.Deployment.WebApi.AppGalleryPackage.Deploy(String deploymentSite, String siteSlotId)
at Microsoft.Web.Deployment.WebApi.DeploymentController.<DownloadAndDeployPackage>d__b.MoveNext()'</message>
</entry>
</entries>
Azure 资源组似乎正在尝试在 Azure Web 应用程序上重新创建我的本地文件夹层次结构。
另一方面,使用使用 Visual Studio --> Publish --> Package 创建的包效果很好。从 VS 手动创建包不是一个选项,我不明白为什么使用 msdeploy.exe 时会失败!!
最佳答案
这里有同样的问题。 已经苦苦挣扎了几天,并已查明问题出在 archive.xml 中的序列化和编码的 MSDeploy.MSDeployProviderOptions 属性值中。该值包含打包文件所源自的原始文件夹结构,Azure 中的 Web 部署尝试在目标系统上重新创建相同的结构。 创建包时使用“-replace”选项运行 msdeploy 对这些序列化选项绝对没有影响(可能是 msdeploy 中的错误?)。
更新
这最终对我有用:
msdeploy.exe
-source:iisApp='C:\Users\alex\AppData\Local\Temp\PublishTemp\TheWorldVS47\wwwroot'
-dest:package='C:\Code\TheWorldVS\PublishOutput\package.zip'
-verb:sync
-enableLink:contentLibExtension
-replace:match='C:\\Users\\alex\\AppData\\Local\\Temp\\PublishTemp\\TheWorldVS47\\',replace='website\'
-retryAttempts:2
-disablerule:BackupRule
-declareParam:name="IIS Web Application Name",kind="ProviderPath",scope="IisApp",match="^C:\\Users\\alex\\AppData\\Local\\Temp\\PublishTemp\\TheWorldVS47",defaultValue="website"
最后一个设置指示 Azure 中的 MSDeploy,默认情况下必须将任何出现的长本地路径替换为“网站”,从而使其发挥作用。 我想您还可以通过在 MSDeploy 扩展 block 的 setParameters 属性内的 ARM json 模板中提供覆盖来进一步自定义该值。
关于c# - Azure Web App 部署 msdeploy 包时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34631035/