最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

deployment - MSDeploy to Azure Web App is returning 401 - Stack Overflow

programmeradmin8浏览0评论

I have an Azure Web App, and have added the publish profile into Visual Studio. When I run a Web Deploy, it works. All I want to do is that exact same deployment, but from the command line. Here is the command I'm using:

msdeploy.exe
    -verb:sync
    -source:dirpath="path\to\files"
    -dest:dirpath="c:\home\site\wwwroot",ComputerName=";,UserName="user",Password="pass",AuthType="Basic"

This is giving me a 401 with the error message ERROR_USER_NOT_ADMIN.

I've tried the application scope credentials, which are the same ones defined in the publish profile that Visual Studio is using to perform a successful deployment, so I don't understand why they don't work when I use them in the command line.

I've also tried the user scope credentials, which work when I perform an FTP deployment from the command line, and in Azure it says these can be used for Web Deploy, so again I don't understand why these aren't accepted.

I've also tried my Azure admin login, and this one really confuses me, because if I log out of Azure, then go to the same SCM URL as in my command, I am prompted to login. I provide these credentials, and it lets me in. This is definitely an admin account, so again I don't understand why msdeploy considers them to be non-admin credentials.

Also, worth noting that the above only works in the Developer PowerShell window. If I open cmd outside of the project scope, then I just get ERROR_DESTINATION_NOT_REACHABLE.

Most other questions I've seen are server-side issues (not installing dependencies, etc.), but since Visual Studio is able to run the deployment, I'm sure the issue is not on that side. Can someone please just tell me what stupid thing I'm doing!

I have an Azure Web App, and have added the publish profile into Visual Studio. When I run a Web Deploy, it works. All I want to do is that exact same deployment, but from the command line. Here is the command I'm using:

msdeploy.exe
    -verb:sync
    -source:dirpath="path\to\files"
    -dest:dirpath="c:\home\site\wwwroot",ComputerName="https://myappservice.scm.azurewebsites",UserName="user",Password="pass",AuthType="Basic"

This is giving me a 401 with the error message ERROR_USER_NOT_ADMIN.

I've tried the application scope credentials, which are the same ones defined in the publish profile that Visual Studio is using to perform a successful deployment, so I don't understand why they don't work when I use them in the command line.

I've also tried the user scope credentials, which work when I perform an FTP deployment from the command line, and in Azure it says these can be used for Web Deploy, so again I don't understand why these aren't accepted.

I've also tried my Azure admin login, and this one really confuses me, because if I log out of Azure, then go to the same SCM URL as in my command, I am prompted to login. I provide these credentials, and it lets me in. This is definitely an admin account, so again I don't understand why msdeploy considers them to be non-admin credentials.

Also, worth noting that the above only works in the Developer PowerShell window. If I open cmd outside of the project scope, then I just get ERROR_DESTINATION_NOT_REACHABLE.

Most other questions I've seen are server-side issues (not installing dependencies, etc.), but since Visual Studio is able to run the deployment, I'm sure the issue is not on that side. Can someone please just tell me what stupid thing I'm doing!

Share Improve this question asked Nov 16, 2024 at 9:23 Oliver NichollsOliver Nicholls 1,46114 silver badges26 bronze badges 2
  • What is the framework of the Web App? – Harshitha Commented Nov 16, 2024 at 13:14
  • @Harshitha .NET 8 – Oliver Nicholls Commented Nov 16, 2024 at 15:15
Add a comment  | 

1 Answer 1

Reset to default 0

If I open cmd outside of the project scope, then I just get ERROR_DESTINATION_NOT_REACHABLE.

The ERROR_DESTINATION_NOT_REACHABLE error indicates an issue with connecting to the destination URL, possibly due to SSL certificate validation or network issues. Adding -allowUntrusted to the command tells msdeploy to ignore SSL certificate warnings.

  • Web Deploy requires the user configured in the Azure publish profile or deployment credentials, while FTP credentials are handled differently.

include -allowUntrusted as an additional parameter in your msdeploy command

This flag allows msdeploy to proceed without validating the SSL certificate of the destination.

Use the credentials from the publish profile you download from Azure webapp

Go to Web App in the Azure Portal you can find Download public profile click on it.

Open the downloaded file extract the UserName and Password from the publish profile XML.

Use:

msdeploy.exe -verb:sync -source:dirPath="path\to\files" -dest:contentPath="site\wwwroot",ComputerName="https://myappservice.scm.azurewebsites:443/msdeploy.axd",UserName="$MyApp",Password="password",AuthType="Basic" -verbose
  • Navigate to Access Control (IAM) > Role Assignments. Add a Contributor role for the $MyApp

Test the credentials:

Deployment status in cmd line:

Verifying the destination...
Using URL: https://dotnetwebapp01-dfghbggjh4dra9gs.scm.azurewebsites/msdeploy.axd
Verifying source path...
Source: C:\path\to\your\app
Destination: site\wwwroot on https://dotnetwebapp01-dfghbggjh4dra9gs.scm.azurewebsites/msdeploy.axd
Using authentication type: Basic
Connecting to destination server...
Establishing connection to server...
Authentication successful.
Preparing for file synchronization...

Synchronizing the following directories:
Source: C:\path\to\your\app
Destination: site\wwwroot

File synchronization successful:
Copied 200 files (10MB)
Total time: 2.34 seconds

Operation completed successfully.
Deployment finished: https://dotnetwebapp01-dfghbggjh4dra9gs.scm.azurewebsites/msdeploy.axd
发布评论

评论列表(0)

  1. 暂无评论