2017-04-25 57 views
2

我嘗試連接到Azure運行方式連接,作爲Powershell腳本的一部分做一個數據庫的備份。Powershell Azure:術語'Get-AutomationConnection'不被識別爲cmdlet,函數,腳本文件或可操作程序的名稱

這個腳本試圖調用Get-AutomationConnection

如截圖所示,Get-Module並返回Azure/Azure.StorageAzureRM節目。

我應該導入哪個模塊以使其工作?

enter image description here

+1

很確定在runbooks中只使用get-automationconnection來檢索數據frmo Azure Automation在內部,你試圖實現什麼? – 4c74356b41

+0

我看到你正在登錄到ARM。你嘗試過Get-AzureRMAutomationConnection嗎? – Niels

+0

https://gallery.technet.microsoft.com/scriptcenter/Backup-Azure-SQL-Databases-bbeea33e - 我想我可以得到一個PowerShell在本地工作,然後將其上傳到天藍色並將其作爲一個函數啓動。嘗試從鏈接到備份Azure SQL數據庫到Blob存儲的鏈接運行powershell –

回答

3

如果要連接到Azure上運行。從Windows PowerShell中的連接,你應該使用New-AzureRmAutomationConnection

$ConnectionAssetName = "AzureRunAsConnection" 
$ConnectionFieldValues = @{"ApplicationId" = $Application.ApplicationId; "TenantId" = $TenantID.TenantId; "CertificateThumbprint" = $Cert.Thumbprint; "SubscriptionId" = $SubscriptionId} 
New-AzureRmAutomationConnection -ResourceGroupName $ResourceGroup -AutomationAccountName $AutomationAccountName -Name $ConnectionAssetName -ConnectionTypeName AzureServicePrincipal -ConnectionFieldValues $ConnectionFieldValues 

您可以使用腳本來創建連接資產,因爲當你創建自動化的帳戶,它會自動包括與連接類型AzurServicePrincipal創建AzureRunAsConnection連接資產器默認一些全球性的模塊。

Get-AutomationConnection在內部運行在Azure Runbook中。

請參考connection assets in Azure Automation

0

如果您想要與本地Runbook具有類似功能,可以安裝AzureAutomationAuthoringToolkit。它會給你非常類似的功能。我有一個使用服務主體登錄的腳本,無論它是在本地還是在Azure Runbook中運行。它在使用內部部署時使用AAATK提供的資源來模擬Runbook。

我曾嘗試使用「Microsoft監視代理程序」(混合工作人員)附帶的Get-AutomationConnection版本,但自那之後我已經讀過它與AzureAutomationAuthoringToolkit附帶的版本不同,詳見「已知問題「在GitHub readme。我無法工作,所以我回到了AAATK的版本。

相關問題