I am trying to access Kudu through power shell script. Link looks like: https://adc-dev.scm.azurewebsites.net
. I need to copy war
file located in D:\home\site\wwwroot\bin\apache-tomcat-8.0.33\webapps
location in above link.
Currently I am deploying the war
file using VSTS by adding FTP task. But before deploying the latest war
I would like to take backup of the old war
in some location in Azure Kudu location say like: D:\home\site\wwwroot\bin\apache-tomcat-8.0.33
(root folder to the war
location). So after that I can remove the war
and deploy the latest war
file in Kudu.
How to do this? I mean how to access kudu using power shell script. Please suggest me.
To access Kudu API, get your WebApp:
Then get publishing credentials for the app:
Format the username/password suitable for a HTTP-request:
Finally, you can access the Kudu API:
Example, check if extension is installed:
Example, get list of available extensions:
Example, install an extension:
API-details are at https://github.com/projectkudu/kudu/wiki/REST-API
Also deployment slots can be accessed. App config needs to be retrieved for the slot and a minor modification of the base URL is needed.
You can refer to this thread below to know how to call Kudu API through Azure PowerShell in VSTS build/release:
Remove files and foldes on Azure before a new deploy from VSTS
Regarding copy file through Kudu, you can use Command Kudu API (Post /api/command):
Kudu REST API
Update:
Simple sample to call Command through Kudu API: