Get PublishingPassword for website with PowerShell for new Azure portal

痞子三分冷 提交于 2019-12-13 01:26:39

问题


I used to use Get-AzureWebsite -Name myportal to get PublishingPassword what I can use inside Visual Studio to publish the WebApp to the cloud.

But now I was assigned with a new azure subscription that is not seen with the old azure command set (i.e. Get-AzureSubscription).

However this subscription is visible by Get-AzureRmSubscription (with "Rm" keyword). But Get-AzureRmWebApp doesn't contain PublishingPassword property.

Is there any other way to get PublishingPassword with new command set (that contains "Rm").


回答1:


The cmdlet you are looking for is Get-AzureRmWebAppPublishingProfile At the time I looked for a more direct method, but didn't turn one up. It is a little bit convoluted, but it works. (it doesn't actually write anything to file, but as I recall it choked if it wasn't included)

This is what I did with it...

function Get-FTPCredentials 
{
    $Xml = [xml](Get-AzureRmWebAppPublishingProfile -OutputFile test.xml -Format Ftp -ResourceGroupName $AppServiceResourceGroupName -Name $AppServiceWebAppName )
    $PublishProfile = $Xml.FirstChild.ChildNodes[1]   
    Write-Output ("FTP location is - " + $PublishProfile.publishUrl) 
    Write-Output ("FTP username is - " + $PublishProfile.userName)
    Write-Output ("FTP password is - " + $PublishProfile.userPWD)

    Write-Output ("Website URL is - " + $PublishProfile.destinationAppUrl)
}



回答2:


Quick flow to get publishing password (PublishingPassword) for a website in Azure published via Visual Studio - manually by using PowerShell console:

Add-AzureRmAccount -TenantId 12343048-34cb-4322-b413-7b408837xxxx

Get-AzureRmWebAppPublishingProfile -Name myPortal -OutputFile test.xml -ResourceGroupName MyResourcesTestGroup

First command sets login to required tenant (directory) (i.e. adds your azure account to PowerShell session). Second gets the website (webapp) objects and prints publishing data including password.



来源:https://stackoverflow.com/questions/36329982/get-publishingpassword-for-website-with-powershell-for-new-azure-portal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!