You are on page 1of 2

param(

[string]$resourceGroupName="RG-EUR-WW-DEV-LHH930-FE",
[string]$webAppName="was-eur-ww-dev-lhh930-cm",
[string]$appPath="wwwroot",
[string]$slotName="",
#[string]$kuduPath="assets/react/js/",
[System.Collections.ArrayList]$kuduPaths=("assets/react/js/a.txt",
"assets/react/js/b.txt"),
#[string[]]$ArgumentList=@['a.txt','b.txt'],
[System.Collections.ArrayList]$testlist= ("a.txt", "b.txt"),
[bool]$recursive=$true
)
function Get-AzureRmWebAppPublishingCredentials($resourceGroupName, $webAppName,
$slotName = $null){
if ([string]::IsNullOrWhiteSpace($slotName)){
$resourceType = "Microsoft.Web/sites/config"
$resourceName = "$webAppName/publishingcredentials"
}
else{
$resourceType = "Microsoft.Web/sites/slots/config"
$resourceName = "$webAppName/$slotName/publishingcredentials"
}
$publishingCredentials = Invoke-AzureRmResourceAction -ResourceGroupName
$resourceGroupName -ResourceType $resourceType -ResourceName $resourceName -Action
list -ApiVersion 2015-08-01 -Force
Write-Host $publishingCredentials
return $publishingCredentials
}
function Get-KuduApiAuthorisationHeaderValue($resourceGroupName, $webAppName,
$slotName = $null){
$publishingCredentials = Get-AzureRmWebAppPublishingCredentials
$resourceGroupName $webAppName $slotName
Write-Host $publishingCredentials.Properties.PublishingUserName
Write-Host $publishingCredentials.Properties.PublishingPassword
return ("Basic {0}" -f
[Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f
$publishingCredentials.Properties.PublishingUserName,
$publishingCredentials.Properties.PublishingPassword))))
}
function Delete-KuduFile($resourceGroupName, $webAppName, $appPath, $slotName,
$kuduPaths, $recursive, $files){
foreach ($kuduPath in $kuduPaths) {
$kuduApiAuthorisationToken = Get-KuduApiAuthorisationHeaderValue
$resourceGroupName $webAppName $slotName
if ($recursive -eq $true) {
if (-not ($kuduPath.endswith("recursive=true"))) {
if (-not ($kuduPath.endswith("/"))) {
$kuduPath += "/"
}
$kuduPath += "?recursive=true"
}
}
if ($slotName -eq ""){
$kuduApiUrl =
"https://$webAppName.scm.azurewebsites.net/api/vfs/site/$appPath/$kuduPath"
}
else{
$kuduApiUrl =
"https://$webAppName`-$slotName.scm.azurewebsites.net/api/vfs/site/$appPath/
$kuduPath"
}

Write-Output $kuduApiUrl
Write-Output $kuduApiAuthorisationToken
Write-Output "Praveen"
try
{
Invoke-RestMethod -Uri $kuduApiUrl `
-Headers @{"Authorization"=$kuduApiAuthorisationToken;"If-
Match"="*"} `
-Method DELETE
#$response = Invoke-RestMethod -Uri $kuduApiUrl `
# -Headers @{"Authorization"=$kuduApiAuthorisationToken;"If-
Match"="*"} `
# -Method GET

#$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"}


-Method GET
#-ContentType #application/json
}catch {
Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
if (-not ($_.Exception.Response.StatusCode.value__ -eq 404)) {
throw $PSItem
}
} }
Write-Output "*********************"
Write-Output $response.name
$files += $response.name
$files += $files
Write-Output $files
Write-Output "*********************"
}

Delete-KuduFile $resourceGroupName $webAppName $appPath $slotName $kuduPaths


$recursive
#Write-Output $testlist
foreach ($item in $testlist) {
Write-Output The value of Item is: $item
}

You might also like