You can achieve this using scripts calling Kudu api. You need to add an azure powershell task in your release pipeline and run kudu api. Below scripts is for example.
1, scripts to create a directory components
$WebApp = Get-AzWebApp -Name '<appname>' -ResourceGroupName '<resourcegroupname>'
[xml]$publishingProfile = Get-AzWebAppPublishingProfile -WebApp $WebApp
# Create Base64 authorization header
$username = $publishingProfile.publishData.publishProfile[0].userName
$password = $publishingProfile.publishData.publishProfile[0].userPWD
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
$bodyToPOST = @{
command = "md components"
dir = "D:\home\site"
}
# Splat all parameters together in $param
$param = @{
# command REST API url
Uri = "https://<appname>.scm.azurewebsites.net/api/command"
Headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}
UserAgent = "powershell/1.0"
Method = "POST"
Body = (ConvertTo-Json $bodyToPOST)
ContentType = "application/json"
}
# Invoke REST call
Invoke-RestMethod @param
Above scripts will first get the username and password from your app's publishprofile which will be used later as anthentication in calling kudu api. And the api will run your self-defined command to make directory components in "d:\home\site"
2, Deploy your app using kudu api.
When the components directory is created, you can invoke kudu api to deploy your app to components directory. Please refer to below example.
$param = @{
# zipdeploy api url
Uri = "https://<appname>.scm.azurewebsites.net/api/zip/site/components"
Headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}
UserAgent = "powershell/1.0"
Method = "PUT"
# Deployment Artifact Path
InFile = "$(System.DefaultWorkingDirectory)\<artifacts_alias>\drop\<artifacts_name>.zip"
ContentType = "multipart/form-data"
}
# Invoke REST call
Invoke-RestMethod @param
The value InFile should point to location of the artifact file which is downloaded by your release pipeline. Usually it is located in "$(System.DefaultWorkingDirectory)\<artifacts_alias>\drop\<artifacts_name>.zip"
For more information about Kudu Api, you can refer to this blog.