有没有办法自动化数据湖分析工作并按计划运行它们?
我正在尝试使用Register-AzureRmAutomationDSCNodecmdlet 将VM加载到Azure Automation DSC ,这是非经典vm的推荐.DSC节点配置已在Azure自动化中导入和编译.
这是我的代码:
$AutomationAccountName = "PersistentAutomationAccount"
$VMName = "VM1"
$AutomationResourceGroup = "PersistantResources"
$VMResourceGroup = "AutomatingAutomation2"
$NodeConfigurationName = "HelloWorldDSC.localhost"
Register-AzureRmAutomationDscNode -AutomationAccountName $AutomationAccountName -AzureVMName $VMName -ResourceGroupName $AutomationResourceGroup -AzureVMResourceGroup $VMResourceGroup -NodeConfigurationName $NodeConfigurationName
Run Code Online (Sandbox Code Playgroud)
但我收到以下错误,我无法找到解释:
New-AzureRmResourceGroupDeployment : 10:56:57 AM - Resource
Microsoft.Compute/virtualMachines/extensions 'VM1/Microsoft.Powershell.DSC' failed with message '{
"error": {
"code": "NotFound",
"target": "vmName",
"message": "The entity was not found."
}
}'
Run Code Online (Sandbox Code Playgroud)
VM名称是正确的,它存在,资源组名称是正确的,所以没有找到什么?我想也许虚拟机需要预先安装扩展,但根据Azure代表,自动化的工作是在节点启用后安装dsc代理/扩展.
我能找到的用于验证 Runbook 的所有示例都使用 AzureRM 模块:
$connectionName = "AzureRunAsConnection"
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName
Add-AzureRmAccount `
-ServicePrincipal `
-TenantId $servicePrincipalConnection.TenantId `
-ApplicationId $servicePrincipalConnection.ApplicationId `
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
Run Code Online (Sandbox Code Playgroud)
但是,如果您使用的是新的 Az 模块,则此代码不起作用,并且您不能在同一个 Runbook 中混合使用AzureRM 模块和Az 模块。如何获得身份验证以使用新的 Az 模块。
我创建了一个Azure SQL DB并将其命名为"TempDb".我想重命名它.我可以通过自动化做到Runbook吗?怎么样?
我需要从另一个 runbook 调用一个 runbook,并在 azure 自动化中获取一个自定义对象作为输出。如果被调用的 Runbook 返回 int 或 string 但无法完成返回自定义对象,则它工作正常。 被调用的 Runbook 的一个简单示例是
workflow CalledRunbook
{
[OutputType([Object])]
$obj1=@{"key1"="value1"}
$obj1
}
Run Code Online (Sandbox Code Playgroud)
现在这个 Runbook 是从 CallingRunbook 调用的,我需要打印这个 obj1
workflow CallingRunbook
{
#After doing proper authentication
$job = Start-AzureAutomationRunbook -Name "CalledRunbook" -AutomationAccountName $AutomationAccountName
$doLoop = $true
while($doLoop) {
Start-Sleep -s 5
$job = Get-AzureAutomationJob -Id $job.Id -AutomationAccountName $AutomationAccountName
$doLoop = (($job.Status -notmatch "Completed") -and ($job.Status -notmatch "Failed") -and ($job.Status -notmatch "Suspended") -and ($job.Status -notmatch "Stopped"))
}
$jobout = Get-AzureAutomationJobOutput `
-Id …Run Code Online (Sandbox Code Playgroud) 我正在尝试获取特定VM的私有IP.我有这个代码正在工作
$vms = get-azurermvm -ResourceGroupName abc
$nics = get-azurermnetworkinterface -ResourceGroupName abc| where VirtualMachine -NE $null #skip Nics with no VM
foreach($nic in $nics)
{
$vm = $vms | where-object -Property Id -EQ $nic.VirtualMachine.id
$prv = $nic.IpConfigurations | select-object -ExpandProperty PrivateIpAddress
Write-Output "$($vm.Name) : $prv"
}
Run Code Online (Sandbox Code Playgroud)
我的VM名es-client-node1,es-client-node2,es-master-node1,es-data-node1和es-data-node1.我想得到客户端节点的IP地址或VM的名称匹配es-client-node*,类似于datanode和主节点到不同的变量
任何想法如何在powershell中做到这一点?