Skip to content

Instantly share code, notes, and snippets.

@takekazuomi
Last active January 22, 2018 18:01
Show Gist options
  • Save takekazuomi/75a92c7eb0f04f474b3d267ec28b0265 to your computer and use it in GitHub Desktop.
Save takekazuomi/75a92c7eb0f04f474b3d267ec28b0265 to your computer and use it in GitHub Desktop.
#Requires -Version 5.1
#Requires -Modules AzureRM.Profile, AzureRM.Websites
[CmdletBinding()]
Param(
$ResourceGroupName,
$Name,
$Path
)
$ErrorActionPreference = "Stop"
$ProgressPreference='SilentlyContinue'
Set-StrictMode -Version latest
[xml]$pp = Get-AzureRmWebAppPublishingProfile -ResourceGroupName $ResourceGroupName -Name $Name -Format WebDeploy
$msd = $pp.publishData.publishProfile | ? { $_.publishMethod -eq 'MSDeploy' } | Select-Object -First 1
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $msd.userName, $msd.userPWD)))
$apiUrl = "https://$webAppName.scm.azurewebsites.net/api/zipdeploy"
Write-Verbose "deploy $Path to $Name" -Verbose:$VerbosePreference
Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization = ("Basic {0}" -f $base64AuthInfo)} -Method POST -InFile $Path -ContentType "multipart/form-data"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment