在咨询 Microsoft 支持后,我可以通过 Azure 自动化使用以下代码启动 Docker 容器:
$connection = Get-AutomationConnection -Name AzureRunAsConnection
$secpasswd = ConvertTo-SecureString "132asdf9asdf342" -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential ("somecontainerregistry", $secpasswd)
Connect-AzureRmAccount -ServicePrincipal -Tenant $connection.TenantID -ApplicationId $connection.ApplicationID -CertificateThumbprint $connection.CertificateThumbprint
New-AzureRmContainerGroup -RegistryCredential $credentials -ResourceGroupName automation-rg -Name jjcontainer03 -Image somecontainerregistry.azurecr.io/etl-pipeline -OsType Linux -DnsNameLabel aci-etl-pipeline-01 -RestartPolicy Never -Command "scrapy crawl data"
当我测试 Azure 自动化门户中的窗格时,这似乎工作正常,但是当我安排它每小时运行时,我只看到 Runbook 作业已执行(在正确的时间),而没有创建新的 Azure 实例。我应该每次都删除旧实例还是我还缺少其他东西?