0

I have a single file that I need to deploy to an existing App Service (that already contains an application, deployed previously through another pipeline).

I would like to avoid using the FTP task for that.

Is there a way to deploy a single file to a specific folder in an App Service via a DevOps Pipeline?

2d1b
  • 595
  • 1
  • 6
  • 24
  • Does this help? https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/copy-files?view=azure-devops&tabs=yaml – Casper Dijkstra Oct 28 '20 at 14:17
  • No because this will copy a file on the build server. What I want is to copy the file to the App Service – 2d1b Oct 28 '20 at 17:03

1 Answers1

1

Actually FTP seems to be the easiest way to deploy single file. However if you don't want to use it you can use KUDU API. What you need is to wrap it in powershell script:

$username = '$(username)'
$password = '$(password)'
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))

$apiUrl = "https://$(siteName).scm.azurewebsites.net/api/vfs/site/your-file"
$filePath = "$(System.DefaultWorkingDirectory)/your-file"
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", ("Basic {0}" -f $base64AuthInfo))
$headers.Add("If-Match", "*")

Invoke-RestMethod -Uri $apiUrl -Headers $headers -Method PUT -InFile $filePath -ContentType "multipart/form-data"

Here you find info how to get credentials.

But if this is one time task you may use drag & drop from KUDU panel as it is mentioned here

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107