I have an ASP.NET Core 2.0 API as an Azure App Service with a deployment slot for QA that I have been using for a few months. I develop in VS2017 and I publish to Azure usin
I think the problem is that Invoke-WebRequest
doesn't honor creds passed in the URL. Instead, you need to pass the basic auth header explicitly.
Try something like this:
$webapp = "MyApp"
$username = "`$MyApp"
$password = "ThePasswordFromPublishProfile"
# Note that the $username here should look like `SomeUserName`, and **not** `SomeSite\SomeUserName`
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))
$apiUrl = "https://$webapp.scm.azurewebsites.net/api/zipdeploy"
$filePath = "C:\Temp\books.zip"
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method POST -InFile $filePath -ContentType "multipart/form-data"
See also here for related info.