This is how you can test your settings that you use in the PowerShell scripts above using Postman.
I found it useful to play with the REST API using Postman to understand what the PowerShell scripts above were doing and understand what status codes I could expect back from the API. I also noticed that the recursive logic for deleting a directory returns a 409 Conflict error even though is DOES delete the files.
In the examples below, my app service is called "YatesDeleteMe"
Create a base 64 encoded username and password string to use below in your authorization header OR run the PowerShell scripts above and it will output one for you
- Download your app service's publish file, which can be downloaded from the Overview tab in the Azure portal.
- Open the file with a text editor
- Find the username (user name example: $YatesDeleteMe ) and password (password example: ch222cDlpCjx4Glq333qo4QywGPMs1cK2Rjrn6phqZ9HswtgEEE12CrhDmcn )
- Create a string out of them and separate them with a colon (should look something like this: $YatesDeleteMe:ch222cDlpCjx4Glq333qo4QywGPMs1cK2Rjrn6phqZ9HswtgEEE12CrhDmcn )
- Base 64 encode them using your own program a site. The result should look something like this: JFlhdGVzRGVsZXRlTWU6Y2gyMjJjRGxwQ2p4NEdscTMzM3FvNFF5d0dQTXMxY0syUmpybjZwaHFaOUhzd3RnRUVFMTJDcmhEbWNu
Retrieve a single file
- Open Postman
- Change the verb to GET
- Enter your URL to the file you want to retrieve (e.g., https://YatesDeleteMe.scm.azurewebsites.net/api/vfs/site/wwwroot/web.config). For more info on paths see this
- Added a header-->
- Key: Authorization
- Value: Basic YourBase64EncodedStringFromAbove
- Left-click the "Send" button and the file will download
Delete a single file
- Open Postman
- Change the verb to DELETE
- Enter your URL to the file you want to delete (e.g., https://YatesDeleteMe.scm.azurewebsites.net/api/vfs/site/wwwroot/web.config)
- Added a header-->
- Key: Authorization
- Value: Basic YourBase64EncodedStringFromAbove
- Added a header-->
- Left-click the "Send" button and the file will deleted
Delete all the files in a directory
- Open Postman
- Change the verb to DELETE
- Enter your URL to the folder you want to delete PLUST add slash and then the query string ?recursive=true (e.g., https://YatesDeleteMe.scm.azurewebsites.net/api/vfs/site/wwwroot/?recursive=true)
- Added a header-->
- Key: Authorization
- Value: Basic YourBase64EncodedStringFromAbove
- Added a header-->
- Left-click the "Send" button and the folder will deleted. I always get a 409 error back, but the folder is deleted.
Reference
- Blog post with pictures here.