在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部署功能。
您可以通过Portal或PowerShell / CLI获取当前凭据。
在门户网站上,webapp刀片顶部有一个按钮,用于下载发布配置文件(不是部署凭据刀片,而是主Web应用程序刀片)。
首先,确保已安装Azure PowerShell cmdlet:https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps?view=azurermps-6.3.0
$PSVersionTable.PSVersion
。确保输出显示您具有主要版本5或更高版本。如果这个命令给你一个错误,那么你正在运行PowerShell v1,这是古老的。Install-Module -Name AzureRM
(可能会提示您更新NuGet,在这种情况下您应该)Import-Module AzureRM
Connect-AzureRmAccount
并完成身份验证过程。$WebAppName
和$ResourceGroupName
:
Get-AzureRmWebAppPublishingProfile
-ResourceGroupName $ResourceGroupName
-Name $WebAppName
-OutputFile creds.xml
-Format WebDeploy
.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>
如果您不熟悉PowerShell,可以尝试使用以下说明来使用azure cli获取部署用户名和密码。
az webapp deployment list-publishing-profiles --name your_web_app_name --resource-group your_resource_group
你还添加--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