Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Samples for using the Azure App Service Kudu REST API to programmatically manage files in your site

Information about the Kudu REST API is found here:

https://github.com/projectkudu/kudu/wiki/REST-API

The VFS API section contains examples for programmatically managing files and directories in the App Service.

Here is an example (written in PowerShell) for listing the files and folders in the wwwroot folder.

$username = “`$websitename”;

$password = “password”;

You can get the publish profile by going to the Overview blade on your App Service, clicking …More at the top of the blade, and then clicking Get publish profile.

#>

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

$userAgent = “powershell/1.0”;

$apiUrl = “https://websitename.scm.azurewebsites.net/api/vfs/site/wwwroot/“;

Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=(“Basic {0}” -f $base64AuthInfo)} -UserAgent $userAgent -Method GET -ContentType “application/json”;

Here is an example that puts a local file from your machine into the App Service file system:

$filePath = “c:temptext.txt”;

$apiUrl = “https://websitename.scm.azurewebsites.net/api/vfs/site/wwwroot/test.txt“;

Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=(“Basic {0}” -f $base64AuthInfo)} -UserAgent $userAgent -Method PUT -InFile $filePath -ContentType “multipart/form-data”;

Share the post

Samples for using the Azure App Service Kudu REST API to programmatically manage files in your site

×

Subscribe to Msdn Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The Msdn Blogs.

Get updates delivered right to your inbox!

Thank you for your subscription

×