Skip to content

Instantly share code, notes, and snippets.

@davideicardi
Last active February 24, 2017 17:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davideicardi/47ea2d1266bf73ba91bfb38306a87947 to your computer and use it in GitHub Desktop.
Save davideicardi/47ea2d1266bf73ba91bfb38306a87947 to your computer and use it in GitHub Desktop.
Deploy a website to azure using web deploy cmd
# $deployCredentials = d3-CreateCredential
# d3-AzureMsDeployWebSite -deployCredentials $deployCredentials -siteName "webplu-test-distribution" -packageDeployCmd "./Deltatre.Forge.DistributionApi.deploy.cmd"
Function d3-AzureMsDeployWebSite
{
param(
[Parameter(Mandatory = $true)]
[PSCredential]$deployCredentials,
[Parameter(Mandatory = $true)]
[string]$siteName,
[Parameter(Mandatory = $true)]
[string]$packageDeployCmd,
[switch]$delete
)
$username = $deployCredentials.Username
$securePassword = $deployCredentials.Password
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePassword)
$UnsecurePassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
$deleteArgs="-enableRule:DoNotDelete"
if ($delete){
$deleteArgs=""
}
$env:_MsDeployAdditionalFlags="-setParam:name=`"IIS Web Application Name`",value=`"$siteName`" $deleteArgs"
& $packageDeployCmd /A:Basic "`"/M:https://$siteName.scm.azurewebsites.net:443/msdeploy.axd?site=$siteName`"" -allowUntrusted /U:$username /P:$UnsecurePassword /Y
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment