Powershell script – get FTP publishing info for Azure web app

Simple script that logs in and grabs the FTP publishing info for an app. I like to just copy and paste stuff into my powershell window so this is exactly that. Replace the variables with your own info and copy/paste it into Powershell. You could convert these to read-host or parameters pretty easily.

<div>$sub = "Subscription Name"</div>
<div>
<div>$site = "AzureWebAppName" #Azure app service</div>
<div>$rg = "ResourceGroupName"</div>
</div>
<div>Login-AzureRmAccount</div>
<div>Set-AzureRmContext -SubscriptionName $sub</div>
<div></div>
<div>$xml = [xml](Get-AzureRmWebAppPublishingProfile -Name $site -ResourceGroupName $rg -OutputFile null)</div>
<div>$username = $xml.SelectNodes("//publishProfile[@publishMethod=`"MSDeploy`"]/@userName").value</div>
<div>$password = $xml.SelectNodes("//publishProfile[@publishMethod=`"MSDeploy`"]/@userPWD").value</div>
<div>$ftp = $xml.SelectNodes("//publishProfile[@publishMethod=`"FTP`"]/@publishUrl").value</div>
<div></div>
<div>Write-Host "FTP Address:" $ftp</div>
<div>Write-Host "FTP Username:" $username</div>
<div>Write-Host "FTP password:" $password</div>

You can also just useĀ Get-AzureRmWebAppPublishingProfile with -FormatĀ FileZilla3 and get a publish settings file to import into FileZilla. Something like


$site = "SiteName"
$rg = "ResourceGroup"
Get-AzureRmWebAppPublishingProfile -ResourceGroupName $rg -Name $site -Format "FileZilla3" -OutputFile "C:\User\UserName\Downloads\$site.xml"

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.