我从哪里获得实际的Azure网站部署密码?

问题描述 投票:23回答:2

在Visual Studio 2015中,当我将我的网站/ Webapp发布到Azure时,我能够自动创建新的发布配置文件(通过输入我的个人Azure帐户凭据),这将创建.pubxml.pubxml.user文件。部署用户名的格式为“$websiteName”,密码由一系列子弹点表示。 .pubxml.user文件包含实际密码,该密码是加密的,只有我的Visual Studio可以读取它,通过使用我的本地Windows用户帐户解密 - 我作为人类,无法看到它。此外,.user文件从源代码管理中排除(但.pubxml文件包含在源代码管理中)。

当我团队中的另一个人尝试部署网站时,他们会获得相同的部署设置,但会提示输入“$website”帐户的密码。我不知道从哪里获取此密码 - Azure管理门户不显示它。

如果此人打开门户并选择重置发布配置文件,那么他们可以下载包含加密密码的新.pubxml文件,我知道只有他们的个人Azure凭据可以解密,但这会破坏我和其他用户的部署,因为现在他们保存的密码(在.user文件中)无效。

我知道这是Azure门户上“部署凭据”刀片的不同用户名+密码,因为当前网站没有设置部署凭据,此外如果我设置一个,则用户名不同。门户网站声明这些凭据无论如何都是用于FTP访问 - 没有提到Web部署功能。

azure deployment
2个回答
40
投票

您可以通过Portal或PowerShell / CLI获取当前凭据。

Azure门户

在门户网站上,webapp刀片顶部有一个按钮,用于下载发布配置文件(不是部署凭据刀片,而是主Web应用程序刀片)。

Screenshot of Azure Portal as of April 2019

Azure PowerShell

首先,确保已安装Azure PowerShell cmdlet:https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps?view=azurermps-6.3.0

  1. 打开提升的PowerShell窗口。
  2. 输入$PSVersionTable.PSVersion。确保输出显示您具有主要版本5或更高版本。如果这个命令给你一个错误,那么你正在运行PowerShell v1,这是古老的。
  3. 输入Install-Module -Name AzureRM(可能会提示您更新NuGet,在这种情况下您应该)
  4. 等待它完成安装。
  5. 输入Import-Module AzureRM
  6. 输入Connect-AzureRmAccount并完成身份验证过程。
  7. 运行此命令可将发布配置文件保存到磁盘上的文件中(为了便于阅读,添加了换行符,实际上将其放在一行中)。在适当的时候设置$WebAppName$ResourceGroupNameGet-AzureRmWebAppPublishingProfile -ResourceGroupName $ResourceGroupName -Name $WebAppName -OutputFile creds.xml -Format WebDeploy

.publishsettings文件

.publishsettings文件是一个XML文件(没有换行符)。在里面你会找到一个具有这种结构的文档。使用userPWD查找<publishProfile>元素中的publishMethod="MSDeploy"属性。不要使用FTP凭据(在第二个<publishProfile>元素中),因为用户名不同。

userPWD属性值未加密,但是是完全随机字节的base64(或base62?)编码。您可以将此值直接复制并粘贴到Visual Studio的发布向导中的凭据提示中。

<publishData>
    <publishProfile
        profileName="SITE - Web Deploy"
        publishMethod="MSDeploy"
        publishUrl="SITE.scm.azurewebsites.net:443"
        msdeploySite="SITE"
        userName="$SITE"
        userPWD="YOUR PASSWORD IS HERE"                    <-- This attribute here
        destinationAppUrl="http://SITE.azurewebsites.net"
        SQLServerDBConnectionString=""
        mySQLDBConnectionString=""
        hostingProviderForumLink=""
        controlPanelLink=""
        webSystem="WebSites"
    >
        <databases />
    </publishProfile>

    <publishProfile
        profileName="SITE - FTP"
        publishMethod="FTP"
        publishUrl="ftp://SITE.ftp.azurewebsites.windows.net/site/wwwroot"
        ftpPassiveMode="True"
        userName="SITE\$SITE"
        userPWD="FTP PASSWORD IS HERE"
        destinationAppUrl="http://SITE.azurewebsites.net"
        SQLServerDBConnectionString=""
        mySQLDBConnectionString=""
        hostingProviderForumLink=""
        controlPanelLink=""
        webSystem="WebSites"
    >
        <databases />
    </publishProfile>
</publishData>

3
投票

如果您不熟悉PowerShell,可以尝试使用以下说明来使用azure cli获取部署用户名和密码。

az webapp deployment list-publishing-profiles --name your_web_app_name --resource-group your_resource_group

enter image description here

你还添加--query来检索“userPWD”

az webapp deployment list-publishing-profiles --name your_web_app_name --resource-group your_resource_group --query '[].userPWD' -o tsv

输出就像

和Marhabettgstfhmohvs 11232342342342342420 Tvklkvk 1 Ksas

© www.soinside.com 2019 - 2024. All rights reserved.