2017-04-12 63 views
0

我一直在运行一个相对简单的脚本来登录到Azure(我得到一个交互式窗口),当我运行一个检查以查看名称是否可用时,我提示再次登录:继续提示通过Powershell登录Azure

# Install the Azure Resource Manager modules from PowerShell Gallery 
# Takes a while to install 28 modules 
Install-Module AzureRM -Force -Verbose 
Install-AzureRM 

# Install the Azure Service Management module from PowerShell Gallery 
Install-Module Azure -Force -Verbose 

# Import AzureRM modules for the given version manifest in the AzureRM module 
Import-AzureRM -Verbose 

# Import Azure Service Management module 
Import-Module Azure -Verbose 

# Authenticate to your Azure account 
Login-AzureRmAccount -SubscriptionId 'xxxxxxxx' 

# Adjust the 'yournamehere' part of these three strings to 
# something unique for you. Leave the last two characters in each. 
$URI  = 'https://someurlhere.com/azuredeploy.json' 
$Location = 'east us' 
$rgname = 'yournamehererg' 
$saname = 'yournameheresa'  # Lowercase required 
$addnsName = 'yournameheread'  # Lowercase required 

# Check that the public dns $addnsName is available 
if (Test-AzureRmDnsAvailability -DomainNameLabel $addnsName -Location $Location) 
{ 'Available' } else { 'Taken. addnsName must be globally unique.' } 

最初登录的作品,展示了我的订阅,但是当我执行最后命令我得到:

Test-AzureRmDnsAvailability : Run Login-AzureRmAccount to login. 

我不能得到任何东西在过去这一点上执行。这真是令人沮丧。感谢任何帮助!

+0

这是否在PowerShell中运行,如果你要单独运行命令?你能确认你使用的AzureRM版本吗? – CtrlDot

+0

是否有任何需要做的事情不受新的Azure CLI 2.0支持? https://docs.microsoft.com/en-us/cli/azure/install-azure-cli - 我一直在OS X,Powershell和Docker容器上使用它,取得了一些成功 – Digicoder

回答

0

根据你的描述,我们应该做一些检查:

1.Run Get-Command Test-AzureRmDnsAvailability找到这个命令:

PS C:\Users> Get-Command Test-AzureRmDnsAvailability 

CommandType  Name            Version Source 
-----------  ----            ------- ------ 
Cmdlet   Test-AzureRmDnsAvailability      3.3.0  AzureRM.Network 

2.Run Get-Module -ListAvailable -Name Azure -Refresh检查Azure的PowerShell的版本,我的天青版本的PowerShell是3.3.0,我能够运行该脚本:

PS C:\Users> Get-Module -ListAvailable -Name Azure -Refresh 


    Directory: C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ServiceManagement 


ModuleType Version Name        ExportedCommands 
---------- ------- ----        ---------------- 
Manifest 3.3.0  Azure        {Get-AzureAutomationCertificate, Get-AzureAutomationConnection, New-AzureAutomationConnection, Remove-AzureAutomationConnection...} 

对于测试中,我们应单独运行Test-AzureRmDnsAvailability

现在,最新发布版本是3.8.0,关于Azure PowerShell的更多信息请参考此link

+0

请让我知道你是否想要进一步的帮助。 –

+0

也可以下载Azure PowerShell安装文件,并将其安装在本地PC上。 https://github.com/Azure/azure-powershell/releases/download/v3.7.0-March2017/azure-powershell.3.7.0.msi –