简体   繁体   中英

How can you delete files from an Azure WebApp using powershell?

Suppose I want to delete all files matching *.config.default from an Azure WebApp. How can I do this with PowerShell? If I had a directory on my local machine I can do this with:

get-childitem -Path . -Filter *.config.default -Recurse | remove-item

I can currently get the webApp using the following, but I don't think this will allow me to delete any files

$webapp = Get-AzureRMWebApp -ResourceGroupName $ResourceGroupName -Name $WebSiteName -ea SilentlyContinue

I know I can use the KUDU console which will allow me access to PS D:\\home\\site\\wwwroot> and then I can use Powershell commands from there, but I need to be able to do this without using the console.

Call the Kudu VFS APIs .

DELETE /api/vfs/{path} -- Delete the file at path.

DELETE https://{site}.scm.azurewebsites.net/api/vfs/wwwroot/some.config.default

If you really want that wildcard, call the command API instead: https://github.com/projectkudu/kudu/wiki/REST-API#command

Of course you should never do this for an app that matters, instead you should make changes to source control and redeploy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM