1
votes

I have the following build step which runs a script in Azure Powershell. The script basically publishes files to the web app (see further down for details).

Azure Powershell

This works just fine with all of my web apps EXCEPT FOR ONE. I get the following error:

scriptCommand= & "C:\a\8b0700333\MyProj\Scripts\Publish.ps1" -websiteName mywebapp -packOutput "C:\a\8b0700333\MyProj\Api"
Stopping web app...
Publishing web app...
Publishing with publish method [MSDeploy]
[error]Error: The specified credentials cannot be used with the authentication scheme 'Basic'.
[error]Error: Default credentials cannot be supplied for the Basic authentication scheme.
[error]Parameter name: authType
[error]Error count: 1.

The Publish.ps1 script:

param($websiteName, $packOutput)

$website = Get-AzureWebsite -Name $websiteName

# get the scm url to use with MSDeploy.  By default this will be the second in the array
$msdeployurl = $website.EnabledHostNames[1]

$publishProperties = @{'WebPublishMethod'='MSDeploy';
                        'MSDeployServiceUrl'=$msdeployurl;
                        'DeployIisAppPath'=$website.Name;
                        'Username'=$website.PublishingUsername;
                        'Password'=$website.PublishingPassword
                        'SkipExtraFilesOnServer'='False'}

Write-Output "Stopping web app..."
Stop-AzureWebsite -Name $websiteName

Write-Output "Publishing web app..."
$publishScript = "${env:ProgramFiles(x86)}\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web Tools\Publish\Scripts\default-publish.ps1"

. $publishScript -publishProperties $publishProperties  -packOutput $packOutput

Write-Output "Starting web app..."
Start-AzureWebsite -Name $websiteName
2
Can't consider this an answer, but check out this blog post from Troy Hunt on this very issue, and a StackOverflow post he made here as well. stackoverflow.com/questions/4210379/… troyhunt.com/2010/11/you-deploying-it-wrong-teamcity_24.htmlFoxDeploy

2 Answers

3
votes

Had the same issue, the problem was coming from the fact that apparently the script Microsoft provides doesn't support slots. Made a fixed version here https://gist.github.com/baywet/f7ed425c48ccde4399c7

Helping myself from this post How can I get the PublishUrl via Azure PowerShell?

1
votes

This error usually occurs when using MS deploy HTTP Basic Authentication without any credentials specified. So you can add following code in the PowerShell script to check if the publish username and password for the web app is get correctly.

Write-Output $website.PublishingUsername
Write-Output $website.PublishingPassword

And also, check the value of msdeployurl to see if it is the correct URL (Usually like: youwebappname.scm.azurewebsites.net) for deployment.

Write-Output $msdeployurl