projectkudu / kudu

Kudu is the engine behind git/hg deployments, WebJobs, and various other features in Azure Web Sites. It can also run outside of Azure.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Msdeploy fails

MaryanneNjeri opened this issue · comments

For deployment issues, please provide us with the following information:

Repro steps.

your project built successfully on your dev machine but failed on Azure?
Am using MsDeploy to create a package, that I later try to deploy to Azure with an Arm template.
I use the command to create the package
msdeploy.exe -source:contentPath="sourcepath" -dest:package="destination\package.zip" -verb:sync

Project structures.

in order to reproduce your issue at our end we need a simple
github repository
that highlights structure of the project

The log/error given by the failure.

ARM-MSDeploy Deploy Failed: 'Microsoft.Web.Deployment.DeploymentDetailedUnauthorizedAccessException: Unable to perform the operation ("Create Directory") for the specified directory ("C:\source\out\bin\package"). 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:\source' is denied.
2021-08-27T19:45:32.5855632Z at Microsoft.Web.Deployment.NativeMethods.RaiseIOExceptionFromErrorCode(Win32ErrorCode errorCode, String maybeFullPath)
2021-08-27T19:45:32.5856156Z at Microsoft.Web.Deployment.DirectoryEx.CreateDirectory(String path)
2021-08-27T19:45:32.5856658Z at Microsoft.Web.Deployment.DirPathProviderBase.CreateDirectory(String fullPath, DeploymentObject source)
2021-08-27T19:45:32.5857185Z at Microsoft.Web.Deployment.DirPathProviderBase.Add(DeploymentObject source, Boolean whatIf)
2021-08-27T19:45:32.5857589Z --- End of inner exception stack trace ---
2021-08-27T19:45:32.5857959Z --- End of inner exception stack trace ---
2021-08-27T19:45:32.5858526Z at Microsoft.Web.Deployment.FilePathProviderBase.HandleKnownRetryableExceptions(DeploymentBaseContext baseContext, Int32[] errorsToIgnore, Exception e, String path, String operation)
2021-08-27T19:45:32.5859128Z at Microsoft.Web.Deployment.DirPathProviderBase.Add(DeploymentObject source, Boolean whatIf)
2021-08-27T19:45:32.5859814Z at Microsoft.Web.Deployment.DeploymentObject.Add(DeploymentObject source, DeploymentSyncContext syncContext)
2021-08-27T19:45:32.5860384Z at Microsoft.Web.Deployment.DeploymentSyncContext.HandleAdd(DeploymentObject destObject, DeploymentObject sourceObject)
2021-08-27T19:45:32.5861049Z at Microsoft.Web.Deployment.DeploymentSyncContext.HandleUpdate(DeploymentObject destObject, DeploymentObject sourceObject)
2021-08-27T19:45:32.5861640Z at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildrenOrder(DeploymentObject dest, DeploymentObject source)
2021-08-27T19:45:32.5862205Z at Microsoft.Web.Deployment.DeploymentSyncContext.SyncChildren(DeploymentObject dest, DeploymentObject source)
2021-08-27T19:45:32.5862788Z at Microsoft.Web.Deployment.DeploymentSyncContext.ProcessSync(DeploymentObject destinationObject, DeploymentObject sourceObject)
2021-08-27T19:45:32.5863501Z at Microsoft.Web.Deployment.DeploymentObject.SyncToInternal(DeploymentObject destObject, DeploymentSyncOptions syncOptions, PayloadTable payloadTable, ContentRootTable contentRootTable, Nullable`1 syncPassId, String syncSessionId)
2021-08-27T19:45:32.5864316Z at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentProviderOptions providerOptions, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)
2021-08-27T19:45:32.5865013Z at Microsoft.Web.Deployment.DeploymentObject.SyncTo(String provider, String path, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)
2021-08-27T19:45:32.5865712Z at Microsoft.Web.Deployment.DeploymentObject.SyncTo(DeploymentWellKnownProvider provider, String path, DeploymentBaseOptions baseOptions, DeploymentSyncOptions syncOptions)
2021-08-27T19:45:32.5866370Z at Microsoft.Web.Deployment.WebApi.AppGalleryPackage.Deploy(String deploymentSite, String siteSlotId, Boolean doNotDelete)
2021-08-27T19:45:32.5866980Z at Microsoft.Web.Deployment.WebApi.DeploymentController.<DownloadAndDeployPackage>d__25.MoveNext()'

Debug your Azure website remotely.

it is recommanded that you share your Web App name, directly or indirectly
we can take a look at what's going on.

Mention any other details that might be useful.

Any assistance will really help, thank you :)


Thanks! We'll be in touch soon.

Creating a .zip of an existing directory

If you want to create an official WebDeploy-formatted .zip archive, you can use MSDeploy with the sync verb, and specify a the source as a contentPath, and the destination as a package.

NOTE: You must use a replace clause to change the source contentPath prefix, to 'website'. Also, note a similar replacement is required in the declareParam argument.

Example:

Assuming that your site content is locally stored at C:\Websites\MyWebSite, and you want to create your MSDeploy package as E:\Temp\msdeploy_my_site_package.zip:

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:contentPath='C:\Websites\MyWebSite',includeAcls=false -dest:package='E:\Temp\msdeploy_my_site_package.zip' -replace:match='C:\\Websites\\MyWebSite\\',replace='website\' -retryAttempts:2 -declareParam:name="IIS Web Application Name",kind="ProviderPath",scope="IisApp",match="^C:\\Websites\\MyWebSite",defaultValue="website" -verbose

Publishing a .zip created by MSDeploy

When publishing, you must replace the declared param "IIS Web Application Name" value with your site name.

Example:

Assuming your created MSDeploy package is in E:\Temp\msdeploy_my_site_package.zip, and your App Service site name is mysite, and that you replace ****UserName**** and ****MyPassword**** with your actual publishing credentials for your App Service site:

"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package='E:\Temp\msdeploy_my_site_package.zip',includeAcls=false -dest:contentPath='mysite',ComputerName='https://mysite.scm.azurewebsites.net:443/msdeploy.axd?site=mysite',UserName='****UserName****',Password='****MyPasword****',AuthType='Basic',includeAcls=False -userAgent:Easy_To_Spot_UA -allowUntrusted -setParam:name='IIS Web Application Name',value='mysite' -verbose

Edit: clarified items to be replaced in the examples.

Thank you @EricSten-MSFT for the quick response, it worked like a charm with the source as iisApp

@MaryanneNjeri - Ah, good feedback. I thought it was clear an obvious that the examples would have to be adapted to the actual paths / site names used by you and your site. I'll make the guidance a little less terse. Thx!