Last active
January 22, 2019 09:16
-
-
Save pacodelacruz/537cca5666f9ebd81ce36d4b7b6264da 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 Upload-FileToWebApp($resourceGroupName, $webAppName, $slotName = "", $localPath, $kuduPath){ | |
$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 " Uploading File to WebApp. Source: '$localPath'. Target: '$virtualPath'..." -ForegroundColor DarkGray | |
Invoke-RestMethod -Uri $kuduApiUrl ` | |
-Headers @{"Authorization"=$kuduApiAuthorisationToken;"If-Match"="*"} ` | |
-Method PUT ` | |
-InFile $localPath ` | |
-ContentType "multipart/form-data" | |
} |
resolves to a directory. Specify a path including a file name, and then retry the command.. The program will terminate in 3 sec.
Add-Content : Cannot bind argument to parameter 'Path' because it is null.
At line:26 char:17
-
Add-content $LogsFullPath -value "[$(Get-Date)]ERROR: $($_.Except ...
-
~~~~~~~~~~~~~
- CategoryInfo : InvalidData: (:) [Add-Content], ParameterBindingValidationException
- FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddContentCommand
Uploading File to WebApp completed
Add-Content : Cannot bind argument to parameter 'Path' because it is null.
At line:31 char:17
-
Add-content $LogsFullPath -value "[$(Get-Date)]Uploading File to ...
-
~~~~~~~~~~~~~
- CategoryInfo : InvalidData: (:) [Add-Content], ParameterBindingValidationException
- FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddContentCommand
PS C:\WebScrape> Get-KuduApiAuthorisationHeaderValue
Get-KuduApiAuthorisationHeaderValue : The term 'Get-KuduApiAuthorisationHeaderValue' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
- Get-KuduApiAuthorisationHeaderValue
-
+ CategoryInfo : ObjectNotFound: (Get-KuduApiAuthorisationHeaderValue:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Could you give an advise. What should I do?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! I try to use it in my script and I get following errors:
resolves to a directory. Specify a path including a file name, and then retry the command.. The program will terminate in 3 sec.
Add-Content : Cannot bind argument to parameter 'Path' because it is null.
At line:26 char:17
Uploading File to WebApp completed
Add-Content : Cannot bind argument to parameter 'Path' because it is null.
At line:31 char:17
PS C:\WebScrape> Get-KuduApiAuthorisationHeaderValue
Get-KuduApiAuthorisationHeaderValue : The term 'Get-KuduApiAuthorisationHeaderValue' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
Could you kindly to give me an advise, please?