Я не могу получить доступ к чему-либо с Azure Automation cmdlets
из лазурной книги. Ниже я успешно получаю все виртуальные машины в своей подписке, но вызов Get-AzureAutomationAccount
возвращает пустую коллекцию (там, где у меня есть 2 учетных записи автоматизации). Любые другие вызовы, которые я могу сделать с помощью автоматизации cmdlets
, возвращают пустые или не найденные исключения.Get-AzureAutomationAccount возвращает пустую коллекцию
Заранее благодарим за любые предложения!
workflow Get-AzureVMTutorial
{
#The name of the Automation Credential Asset this runbook will use to authenticate to Azure.
$CredentialAssetName = 'AaronCred'
#Get the credential with the above name from the Automation Asset store
$Cred = Get-AutomationPSCredential -Name $CredentialAssetName
if(!$Cred) {
Throw "Could not find an Automation Credential Asset named '${CredentialAssetName}'. Make sure you have created one in this Automation Account."
}
#Connect to your Azure Account
$Account = Add-AzureAccount -Credential $Cred
if(!$Account) {
Throw "Could not authenticate to Azure using the credential asset '${CredentialAssetName}'. Make sure the user name and password are correct."
}
#TODO (optional): pick the right subscription to use. Without this line, the default subscription for your Azure Account will be used.
#Select-AzureSubscription -SubscriptionName "TODO: your Azure subscription name here"
#Get all the VMs you have in your Azure subscription
$VMs = Get-AzureVM
#Print out up to 10 of those VMs
if(!$VMs) {
Write-Output "No VMs were found in your subscription."
} else {
Write-Output $VMs[0..9]
}
# PROBLEM - No accounts are returned even though I have 2
$automationAccounts = Get-AzureAutomationAccount
#Print out up to 10 of those automation accounts
if(!$automationAccounts) {
Write-Output "No automation accounts were found in your subscription."
} else {
Write-Output $VMs[0..9]
}
}
я исключительно с помощью portal.azure.com, на самом деле счет автоматизации был создан только для тестирования этой проблемы вчера через portal.azure.com. –
OK, вам нужно использовать командлеты, соответствующие этому порталу: Add-AzureRmAccount, Get-AzureRmAutomationAccount, Get-AzureRmAutomationRunbook и т. Д., Как говорится в этом ответе. Get-AzureAutomationAccount - это командлет, который соответствует старому порталу. – Joe
Это правильный ответ. Большое спасибо Джо. Чтение ссылки, которую вы отправили, я обнаружил, что мне нужно использовать командлеты Azure Resource Manager (https://msdn.microsoft.com/en-us/library/mt244122.aspx), когда я создаю свою учетную запись автоматизации Azure через portal.azure.com , К сожалению, их главная страница прямо сейчас на https://azure.microsoft.com/en-us/documentation/services/automation/ (Automate-> Automation Cmdlets) указывает на старую документацию, что я и ошибочно использовал. –