Pierre Murasso
Pierre Murasso

Reputation: 601

ERROR on Azure Web App Deployment of a msdeploy package

I encounter an error while deploying a package on an azure web app.

The app is a .NET web application, compiled for 4.0 framework.

Here is the command line I use for creating the package:

"msdeploy.exe" -verb:sync -source:dirpath="C:\Users\Pierre\Documents\Projets\MyProject\MyApp" -dest:package=C:\Users\Pierre\Documents\MyProject\AzureResourceGroup\MyApp.zip

Then, on deployment using azure resource groups templates I get the following error

<?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. ---&gt; Microsoft.Web.Deployment.DeploymentException: The error code was 0x80070005. ---&gt; 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.&lt;DownloadAndDeployPackage&gt;d__b.MoveNext()'</message>
  </entry>
</entries>

It seems like the azure resource group is trying to recreate my local folders hierarchy on the azure web app.

On the other side, using a package created with Visual Studio --> Publish --> Package works fine. Manually creating the package from VS is not an option, and I can't understand why it fails when msdeploy.exe is used !!

Upvotes: 0

Views: 2554

Answers (2)

Alex Lobakov
Alex Lobakov

Reputation: 714

Same issue here. Been struggling for several days now, and have pinpointed the problem to be in the serialized and encoded MSDeploy.MSDeployProviderOptions attribute value in archive.xml. The value contains the original folder structure from which the packaged files originated, and Web Deploy in Azure attempts to recreate the same structure on the target system. Running msdeploy with the "-replace" option when creating a package has absolutely no effect on those serialized options (could be a bug in msdeploy?).

UPDATE

Here's what finally worked for me:

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"

This last setting is what made it work by instructing MSDeploy in Azure that any occurrences of that long local path must be replaced with "website" by default. I suppose you could also further customize that value by providing an override for it in the ARM json template within the setParameters property of your MSDeploy extension block.

Upvotes: 3

David Ebbo
David Ebbo

Reputation: 43203

Try using contentpath instead of dirpath, e.g.

"msdeploy.exe" -verb:sync -source:contentpath="C:\Users\Pierre\Documents\Projets\MyProject\MyApp" -dest:package=C:\Users\Pierre\Documents\MyProject\AzureResourceGroup\MyApp.zip

Upvotes: 1

Related Questions