Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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