Guest User

Untitled

a guest
Oct 8th, 2018
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. param (
  2. [Parameter(Mandatory=$true)]
  3. [string]$PublishSettingsFile,
  4. [Parameter(Mandatory=$true)]
  5. [string]$DeploymentBatch,
  6. [Parameter(Mandatory=$true)]
  7. [string]$WebAppUrl,
  8. [switch]$Deploy
  9. )
  10.  
  11. # generate the kudu address for the Azure Web App url
  12. function GetTargetDeploymentUrl
  13. {
  14. param (
  15. [Parameter(Mandatory=$true)]
  16. [string]$Url
  17. )
  18.  
  19. $result = ""
  20.  
  21. $i = $Url.IndexOf(".")
  22.  
  23. if ($i -ge 0)
  24. {
  25. $result = $Url.Insert($i, ".scm")
  26. }
  27.  
  28. return $result
  29. }
  30.  
  31. # read the deployment credentials from the publish settings file
  32. [xml]$publishSettings = Get-Content $PublishSettingsFile
  33.  
  34. $webDeployNode = $publishSettings.SelectSingleNode("/publishData/publishProfile[@publishMethod='MSDeploy']")
  35.  
  36. $userName = $webDeployNode.userName
  37. $password = $webDeployNode.userPWD
  38.  
  39. # get the web address to deploy to
  40. $deploymentUrl = GetTargetDeploymentUrl -Url $WebAppUrl
  41.  
  42. if ($deploymentUrl -eq "")
  43. {
  44. Write-Host -ForegroundColor Red "Cannot generate target deployment url."
  45. }
  46. else
  47. {
  48. # call the deployment batch and perform deployment
  49. Write-Host -ForegroundColor Magenta "Deploy to $deploymentUrl"
  50.  
  51. $deploymentUrl = $deploymentUrl + "/MSDeploy.axd"
  52.  
  53. if ($Deploy -eq $True)
  54. {
  55. & $DeploymentBatch /Y "/M:$deploymentUrl" /U:$userName /P:$password /a:Basic
  56. }
  57. else
  58. {
  59. & $DeploymentBatch /T "/M:$deploymentUrl" /U:$userName /P:$password /a:Basic
  60. }
  61. }
  62.  
  63. Write-Host -ForegroundColor Green "Done."
Add Comment
Please, Sign In to add comment