Azure Web App部署msdeploy包时出错
本文关键字:包时 出错 msdeploy 部署 Web App Azure | 更新日期: 2023-09-27 18:29:05
在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-->发布-->包创建的包也可以正常工作。从VS手动创建包不是一个选项,我不明白为什么使用msdeploy.exe时会失败
这里也有同样的问题。几天来,我一直在努力,并已在archive.xml中的序列化和编码的MSDeploy.MSDeployProviderOptions属性值中找到了问题。该值包含打包文件的原始文件夹结构,Azure中的Web Deploy尝试在目标系统上重新创建相同的结构。在创建包时使用"-replaces"选项运行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扩展块的setParameters属性中的ARMjson模板中为该值提供覆盖来进一步自定义该值。
尝试使用contentpath而不是dirpath,例如
"msdeploy.exe" -verb:sync -source:contentpath="C:'Users'Pierre'Documents'Projets'MyProject'MyApp" -dest:package=C:'Users'Pierre'Documents'MyProject'AzureResourceGroup'MyApp.zip