Last active
April 13, 2017 05:44
-
-
Save pacodelacruz/35ed6993b7a1c9e1322c51244def2569 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Download-FileFromWebApp($resourceGroupName, $webAppName, $slotName = "", $kuduPath, $localPath){ | |
$kuduApiAuthorisationToken = Get-KuduApiAuthorisationHeaderValue $resourceGroupName $webAppName $slotName | |
if ($slotName -eq ""){ | |
$kuduApiUrl = "https://$webAppName.scm.azurewebsites.net/api/vfs/site/wwwroot/$kuduPath" | |
} | |
else{ | |
$kuduApiUrl = "https://$webAppName`-$slotName.scm.azurewebsites.net/api/vfs/site/wwwroot/$kuduPath" | |
} | |
$virtualPath = $kuduApiUrl.Replace(".scm.azurewebsites.", ".azurewebsites.").Replace("/api/vfs/site/wwwroot", "") | |
Write-Host " Downloading File from WebApp. Source: '$virtualPath'. Target: '$localPath'..." -ForegroundColor DarkGray | |
Invoke-RestMethod -Uri $kuduApiUrl ` | |
-Headers @{"Authorization"=$kuduApiAuthorisationToken;"If-Match"="*"} ` | |
-Method GET ` | |
-OutFile $localPath ` | |
-ContentType "multipart/form-data" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment