Azure 程序自動化功能支援數種類型的 Runbook,如下表所定義。
| 類型 |
描述 |
PowerShell (建議) |
基於 Windows PowerShell 指令碼的文字型運作手冊。 目前支援的版本是 PowerShell 7.4 和 PowerShell 5.1。 由於父產品 PowerShell 不再支援 PowerShell 7.1 和 PowerShell 7.2,因此建議您在長期支援的 PowerShell 7.4 版本中建立 Runbook。 |
|
PowerShell 工作流程 |
以 Windows PowerShell 工作流程指令碼為基礎的文字式操作手冊。 |
Python(編程語言) (建議) |
以 Python 腳本為基礎的文字式運行手冊。 目前支援的版本是 Python 3.10。 由於父產品 Python 不再支援 Python 2.7 和 Python 3.8,因此建議您在 Python 3.10 中建立 Runbook。 |
|
圖形化 |
圖形化 Runbook 是以 Windows PowerShell 為基礎,而且完全在 Azure 入口網站的圖形化編輯器中建立和編輯。 |
|
圖形化 PowerShell 工作流程 |
圖形化 Runbook 是以 Windows PowerShell 工作流程為基礎,而且完全在 Azure 入口網站的圖形化編輯器中建立和編輯。 |
若要了解流程自動化環境,請參閱 Azure 自動化中的 Runbook 執行。
附註
Azure Automation 將依據母產品 PowerShell 與 Python 發布的時間軸,遵循 PowerShell 與 Python 版本的支援生命週期。 我們建議您搭配支援的語言版本使用 Runbook。
在決定要針對特定 Runbook 使用何種類型時,請考慮下列考量:
- 您無法將 Runbook 從圖形化類型轉換為文字類型,反之亦然。
- 使用不同類型的 Runbook 作為子 Runbook 時有所限制。 如需更多資訊,請參閱Azure 自動化中的子流程手冊。
PowerShell 運行手冊
PowerShell Runbook 以 Windows PowerShell 為基礎。 您可以直接使用 Azure 入口網站的文字編輯器來編輯 Runbook 的程式碼。 您也可以使用任何離線文字編輯器,並 匯入 Runbook 到 Azure 自動化。
PowerShell 版本是由指定的 運行時間版本 所決定。
相同的 Azure 沙箱和混合式 Runbook 背景工作角色可以並行執行多個以不同執行階段版本為目標的 PowerShell Runbook。
附註
- 目前,除了巴西東南部和 Gov 雲端以外,所有公用區域中的雲端和混合式作業都支援 PowerShell 7.4 運行時間版本。
- 在執行 Runbook 時,如果您選取 [運行時間版本] 作為 7.4,則會使用以 7.4 運行時間版本為目標的 PowerShell 模組,而如果您選取 [運行時間版本] 作為 5.1,則會使用以 5.1 運行時間版本為目標的 PowerShell 模組。
請確定您為模組選取正確的 run-time 版本。
例如:如果您要在 運行時間7.4 版中執行 SharePoint 自動化案例的 Runbook,請在 運行時間版本 7.4 中匯入模組;如果您要在 運行時間5.1 版中執行 SharePoint 自動化案例的 Runbook,請在 運行時間5.1 版中匯入模組。
優點
- 使用 PowerShell 程式碼實作所有複雜的邏輯,不必處理 PowerShell 工作流程的其他複雜性。
- 啟動速度會比 PowerShell 工作流程 Runbook 更快,因為其在執行之前不需要編譯。
- 在 Azure 中執行,以及在 Windows 和 Linux 的混合式 Runbook 工作角色上運行。
限制與已知問題
以下是 PowerShell Runbook 目前限制與已知的問題:
限制
附註
目前,除了巴西東南部和 Gov 雲端以外,所有公用區域中的雲端和混合式作業都支援 PowerShell 7.4 運行時間版本。
- Powershell 7.4 僅適用於 運行時間環境體驗。
- 針對 PowerShell 7.4 執行階段版本,不會提取匯入模組的模組活動。 使用 適用於 VS Code 的 Azure 自動化擴充功能 來簡化 Runbook 撰寫體驗。
- PowerShell 7.x 不支援工作流程。 如需詳細資訊,請參閱 PowerShell 工作流程。
- PowerShell 7.x 目前不支援已簽署的執行手冊。
- 原始檔控制整合不支援PowerShell 7.4。 此外,原始程式碼控制中的 PowerShell 7.4 Runbook 在自動化帳戶中建立時會採用執行階段 5.1。
- 默認會安裝 Az module 12.3.0。 一旦使用 Azure 入口網站或 API 再次設定 Az 版本,就會顯示所選 Az 模組版本的完整元件模組清單。
- 匯入的 PowerShell 7.4 模組會在作業執行期間進行驗證。 確定選取模組的所有相依性也會匯入,以成功執行作業。
- Azure Runbook 不支援使用
Start-Job 搭配使用 -credential。
- Azure 不支援所有 PowerShell 輸入參數。
深入了解。
已知問題
依賴內部檔案路徑的執行手冊(例如 C:\modules)可能會因服務後端基礎設施的變更而無法運作。 變更 Runbook 程式碼以確保沒有任何內部檔案路徑相依性,並使用 Get-ChildItem 來取得必要的模組資訊。
Get-AzStorageAccount Cmdlet 可能失敗並發生錯誤:在模組 Get-AzStorageAccount 中發現 Az.Storage 命令,但該模組無法載入。
不支援使用 .\child-runbook.ps1 執行子指令碼。
因應措施:使用 Start-AutomationRunbook(內部 cmdlet)或 Start-AzAutomationRunbook(從 Az.Automation 模組),從父指令碼啟動另一個指令碼。
當您使用 ExchangeOnlineManagement 模組 3.0.0 版或更高版本時,可能會遇到錯誤。 若要解決此問題,請確定您已明確上傳 PowerShellGet 和 PackageManagement 模組。
當您在 Az.Automation Module 中使用 New-AzAutomationVariable Cmdlet 來上傳類型為物件的變數時,作業不會如預期般運作。
因應措施:使用 ConvertTo-Json Cmdlet 將對象轉換成 JSON 字串,然後將變數與 JSON 字串作為其值上傳。 此因應措施可確保將 Azure 自動化環境內的變數適當處理為 JSON 字串。
範例 - 建立已儲存 Azure VM 相關資訊的 PowerShell 物件
azurepowershell
# Retrieve Azure virtual machines with status information for the 'northeurope' region
$AzVM = Get-AzVM -Status | Where-Object {$_.Location -eq "northeurope"}
$VMstopatch = @($AzVM).Id
# Create an Azure Automation variable (This cmdlet will not fail, but the variable may not work as intended when used in the runbook.)
New-AzAutomationVariable -ResourceGroupName "mrg" -AutomationAccountName "mAutomationAccount2" -Name "complex1" -Encrypted $false -Value $VMstopatch
# Convert the object to a JSON string
$jsonString = $VMstopatch | ConvertTo-Json
# Create an Azure Automation variable with a JSON string value (works effectively within the automation runbook)
New-AzAutomationVariable -ResourceGroupName "mrg" -AutomationAccountName "mAutomationAccount2" -Name "complex1" -Encrypted $false -Value $jsonString
限制
附註
父產品 PowerShell 不再支援 PowerShell 7.2 版。
- 若使用 PowerShell 7.2 執行階段版本,則不會針對匯入的模組擷取模組活動。
- PowerShell 7.x 不支援工作流程。 如需詳細資訊,請參閱 PowerShell 工作流程。
- PowerShell 7.x 目前不支援已簽署的執行手冊。
- 原始程式碼控制整合不支援 PowerShell 7.2。 此外,原始程式碼控制中的 PowerShell 7.2 Runbook 在自動化帳戶中建立時會採用執行階段 5.1。
- 依照預設,會安裝 Az 模組 8.3.0。 一旦使用 Azure 入口網站或 API 再次設定 Az 版本,就會顯示所選 Az 模組版本的完整元件模組清單。
- 匯入的 PowerShell 7.2 模組會在作業執行期間進行驗證。 確定選取模組的所有相依性也會匯入,以成功執行作業。
- Azure Runbook 不支援使用
Start-Job 搭配使用 -credential。
- Azure 不支援所有 PowerShell 輸入參數。
深入了解。
已知問題
依賴內部檔案路徑的執行手冊(例如 C:\modules)可能會因服務後端基礎設施的變更而無法運作。 變更 Runbook 程式碼以確保沒有任何內部檔案路徑相依性,並使用 Get-ChildItem 來取得必要的模組資訊。
Get-AzStorageAccount Cmdlet 可能失敗並發生錯誤:在模組 Get-AzStorageAccount 中發現 Az.Storage 命令,但該模組無法載入。
不支援使用 .\child-runbook.ps1 執行子指令碼。
因應措施:使用 Start-AutomationRunbook(內部 cmdlet)或 Start-AzAutomationRunbook(從 Az.Automation 模組),從父指令碼啟動另一個指令碼。
當您使用 ExchangeOnlineManagement 模組 3.0.0 版或更高版本時,可能會遇到錯誤。 若要解決此問題,請確定您已明確上傳 PowerShellGet 和 PackageManagement 模組。
當您在 Az.Automation Module 中使用 New-AzAutomationVariable Cmdlet 來上傳類型為物件的變數時,作業不會如預期般運作。
因應措施:使用 ConvertTo-Json Cmdlet 將對象轉換成 JSON 字串,然後將變數與 JSON 字串作為其值上傳。 此因應措施可確保將 Azure 自動化環境內的變數適當處理為 JSON 字串。
範例 - 建立已儲存 Azure VM 相關資訊的 PowerShell 物件
azurepowershell
# Retrieve Azure virtual machines with status information for the 'northeurope' region
$AzVM = Get-AzVM -Status | Where-Object {$_.Location -eq "northeurope"}
$VMstopatch = @($AzVM).Id
# Create an Azure Automation variable (This cmdlet will not fail, but the variable may not work as intended when used in the runbook.)
New-AzAutomationVariable -ResourceGroupName "mrg" -AutomationAccountName "mAutomationAccount2" -Name "complex1" -Encrypted $false -Value $VMstopatch
# Convert the object to a JSON string
$jsonString = $VMstopatch | ConvertTo-Json
# Create an Azure Automation variable with a JSON string value (works effectively within the automation runbook)
New-AzAutomationVariable -ResourceGroupName "mrg" -AutomationAccountName "mAutomationAccount2" -Name "complex1" -Encrypted $false -Value $jsonString
限制
- Runbook 無法使用平行處理來平行執行多個動作。
- 發生錯誤時,Runbook 無法使用檢查點來繼續執行 Runbook。
- 您可以使用 Start-AzAutomationRunbook Cmdlet (其會建立新的工作),只將 PowerShell、PowerShell 工作流程 Runbook 和圖形化 Runbook 包含為子 Runbook。
- Runbook 無法使用 PowerShell #Requires 陳述式,因為 Azure 沙盒環境或混合式 Runbook 執行者不支援此功能,且可能會導致作業失敗。
- Azure Runbook 不支援使用
Start-Job 搭配使用 -credential。
- Azure 不支援所有 PowerShell 輸入參數。
深入了解。
已知問題
依賴內部檔案路徑的執行手冊(例如 C:\modules)可能會因服務後端基礎設施的變更而無法運作。 變更 Runbook 程式碼以確保沒有任何內部檔案路徑相依性,並使用 Get-ChildItem 來取得必要的模組資訊。
範例指令碼
# Get information about module "Microsoft.Graph.Authentication"
$ModuleName = "Microsoft.Graph.Authentication"
$NewPath = "C:\usr\src\PSModules\$ModuleName"
$OldPath = "C:\Modules\User\$ModuleName"
if (Test-Path -Path $NewPath -PathType Container) {
Get-ChildItem -Path $NewPath
} elseif (Test-Path -Path $OldPath -PathType Container) {
Get-ChildItem -Path $OldPath
} else {
Write-Output "Module $ModuleName not present."
}
# Getting the path to the Temp folder, if needed.
$tmp = $env:TEMP
Get-AzStorageAccount Cmdlet 可能失敗並發生錯誤:在模組 Get-AzStorageAccount 中發現 Az.Storage 命令,但該模組無法載入。
PowerShell Runbook 無法擷取具有 Null 值的未加密變數資產。
PowerShell Runbook 無法擷取名稱中含有 *~* 的變數資產。
PowerShell Runbook 中在迴圈中重複執行的 Get-Process 作業大約在 80 次反覆運算之後會崩潰。
如果 PowerShell Runbook 嘗試同時將大量資料寫入輸出資料流,則可能會失敗。 在處理大型物件時,讓 Runbook 只輸出所需的資訊,通常就可以解決這個問題。 例如,不是使用沒有限制的 Get-Process,而是讓 Cmdlet 只輸出必要參數,如 Get-Process | Select ProcessName, CPU 中所示。
當您使用 ExchangeOnlineManagement 模組 3.0.0 版或更高版本時,可能會遇到錯誤。 若要解決此問題,請確定您已明確上傳 PowerShellGet 和 PackageManagement 模組。
如果您使用 2.12.3 版或更新版本匯入模組 Az.Accounts,請務必明確匯入 Newtonsoft.Json v10 模組 (如果 PowerShell 5.1 Runbook 相依於此版本的模組)。 此問題的因應措施是使用 PowerShell 7.2 Runbook。
當您在 Az.Automation Module 中使用 New-AzAutomationVariable Cmdlet 來上傳類型為物件的變數時,作業不會如預期般運作。
因應措施:使用 ConvertTo-Json Cmdlet 將對象轉換成 JSON 字串,然後將變數與 JSON 字串作為其值上傳。 此因應措施可確保將 Azure 自動化環境內的變數適當處理為 JSON 字串。
範例 - 建立已儲存 Azure VM 相關資訊的 PowerShell 物件
# Retrieve Azure virtual machines with status information for the 'northeurope' region
$AzVM = Get-AzVM -Status | Where-Object {$_.Location -eq "northeurope"}
$VMstopatch = @($AzVM).Id
# Create an Azure Automation variable (This cmdlet will not fail, but the variable may not work as intended when used in the runbook.)
New-AzAutomationVariable -ResourceGroupName "mrg" -AutomationAccountName "mAutomationAccount2" -Name "complex1" -Encrypted $false -Value $VMstopatch
# Convert the object to a JSON string
$jsonString = $VMstopatch | ConvertTo-Json
# Create an Azure Automation variable with a JSON string value (works effectively within the automation runbook)
New-AzAutomationVariable -ResourceGroupName "mrg" -AutomationAccountName "mAutomationAccount2" -Name "complex1" -Encrypted $false -Value $jsonString
限制
- 父產品 PowerShell 不再支援 PowerShell 7.1。 建議您在 PowerShell 7.4 中建立新的 Runbooks,以獲得長期支援,並更新舊的 Runbooks。
- Linux 混合式 Runbook 背景工作角色不支援 Azure 自動化內部 PowerShell Cmdlet。 您必須在 PowerShell Runbook 的開頭匯入
automationassets 模組,才能存取自動化帳戶共用資源 (資產) 函式。
- 對於 PowerShell 7 執行階段版本,不會擷取匯入模組的活動。
- PowerShell 7 執行階段版本不支援 PSCredential Runbook 參數型別。
- PowerShell 7.x 不支援工作流程。 如需詳細資訊,請參閱 PowerShell 工作流程。
- PowerShell 7.x 目前不支援已簽署的執行手冊。
- 原始檔控制整合不支援 PowerShell 7.1 (預覽),此外原始檔控制中的 PowerShell 7.1 (預覽) 會在自動化帳戶中建立 Runbook 作為 run-time 5.1。
- PowerShell 7.1 模組管理並未透過
Get-AzAutomationModule Cmdlet 支援。
- 如果輸入值包含「'」字元,Runbook 會失敗且沒有記錄追蹤。
- Azure Runbook 不支援使用
Start-Job 搭配使用 -credential。
- Azure 不支援所有 PowerShell 輸入參數。
深入了解。
已知問題
依賴內部檔案路徑的執行手冊(例如 C:\modules)可能會因服務後端基礎設施的變更而無法運作。 變更 Runbook 程式碼以確保沒有任何內部檔案路徑相依性,並使用 Get-ChildItem 來取得必要的模組資訊。
範例指令碼
# Get information about module "Microsoft.Graph.Authentication"
$ModuleName = "Microsoft.Graph.Authentication"
$NewPath = "C:\usr\src\PSModules\$ModuleName"
$OldPath = "C:\Modules\User\$ModuleName"
if (Test-Path -Path $NewPath -PathType Container) {
Get-ChildItem -Path $NewPath
} elseif (Test-Path -Path $OldPath -PathType Container) {
Get-ChildItem -Path $OldPath
} else {
Write-Output "Module $ModuleName not present."
}
# Getting the path to the Temp folder, if needed.
$tmp = $env:TEMP
Get-AzStorageAccount Cmdlet 可能失敗並發生錯誤:在模組 Get-AzStorageAccount 中發現 Az.Storage 命令,但該模組無法載入。
在此預覽中不支援使用 .\child-runbook.ps1 執行子指令碼。
因應措施:使用 Start-AutomationRunbook (內部 Cmdlet) 或 Start-AzAutomationRunbook (從 Az.Automation 模組),從父代 Runbook 啟動另一個 Runbook。
PowerShell 7 執行階段不支援定義記錄偏好設定的 Runbook 屬性。
因應措施:在運行手冊開頭明確設定偏好設定,如下所示:
$VerbosePreference = "Continue"
$ProgressPreference = "Continue"
避免將模組 Az.Accounts 匯入至 PowerShell 7 的 2.4.0 版執行環境,因為在 Azure 自動化中可能會出現非預期的行為。
針對在 PowerShell 7 run-time 中執行的作業,可能會發生錯誤輸出資料流程的格式問題。
當您匯入相依於其他模組的 PowerShell 7.1 模組時,您可能會發現即使已安裝相依模組的 PowerShell 7.1 版本,匯入按鈕也會呈現灰色。 例如,Az PowerShell module.Compute 4.20.0 版相依於 Az.Accounts,為 >= 2.6.0。 當 PowerShell 5.1 中的對等相依模組不符合版本需求時,就會發生此問題。 例如,Az.Accounts 的 5.1 版是 < 2.6.0。
當您使用 Webhook 開始 PowerShell 7 Runbook,會將 Webhook 輸入參數自動轉換成不正確的 JSON。
建議您使用 ExchangeOnlineManagement 模組 3.0.0 版或更早的版本,因為 3.0.0 版或更高版本可能會導致作業失敗。
如果您使用 2.12.3 版或更新版本匯入模組 Az.Accounts,請務必明確匯入 Newtonsoft.Json v10 模組 (如果 PowerShell 7.1 Runbook 相依於此版本的模組)。 此問題的因應措施是使用 PowerShell 7.2 Runbook。
當您在 Az.Automation Module 中使用 New-AzAutomationVariable Cmdlet 來上傳類型為物件的變數時,作業不會如預期般運作。
因應措施:使用 ConvertTo-Json Cmdlet 將對象轉換成 JSON 字串,然後將變數與 JSON 字串作為其值上傳。 此因應措施可確保將 Azure 自動化環境內的變數適當處理為 JSON 字串。
範例 - 建立已儲存 Azure VM 相關資訊的 PowerShell 物件
# Retrieve Azure virtual machines with status information for the 'northeurope' region
$AzVM = Get-AzVM -Status | Where-Object {$_.Location -eq "northeurope"}
$VMstopatch = @($AzVM).Id
# Create an Azure Automation variable (This cmdlet will not fail, but the variable may not work as intended when used in the runbook.)
New-AzAutomationVariable -ResourceGroupName "mrg" -AutomationAccountName "mAutomationAccount2" -Name "complex1" -Encrypted $false -Value $VMstopatch
# Convert the object to a JSON string
$jsonString = $VMstopatch | ConvertTo-Json
# Create an Azure Automation variable with a JSON string value (works effectively within the automation runbook)
New-AzAutomationVariable -ResourceGroupName "mrg" -AutomationAccountName "mAutomationAccount2" -Name "complex1" -Encrypted $false -Value $jsonString
PowerShell Workflow 執行手冊
PowerShell Workflow Runbook 是以 Windows PowerShell 工作流程為基礎的文字 Runbook。 您可以直接使用 Azure 入口網站的文字編輯器來編輯 Runbook 的程式碼。 您也可以使用任何離線文字編輯器,並 匯入 Runbook 到 Azure 自動化。
附註
PowerShell 7.1 (預覽版) 和 PowerShell 7.2 不支援工作流程執行手冊。
優點
- 使用 PowerShell 工作流程程式碼實作所有複雜的邏輯。
- 發生錯誤時,使用檢查點來繼續執行作業。
- 使用平行處理來平行執行多個動作。
- 可併入其他圖形化 Runbook 和 PowerShell 工作流程 Runbook 成為子 Runbook,以建立高階工作流程。
限制
- PowerShell 7+ 版本中不支援 PowerShell 工作流程。 因此,無法升級過期的 Runbook。
- 相較於較新的 PowerShell 7+ 版本,平行執行的處理效率不佳。
- PowerShell 工作流程在內部使用多個程序運作。 因此,一個程序中可用的模組可能無法在另一個程序中使用,並導致找不到命令等例外狀況。
- Runbook 必須處理 PowerShell 工作流程的其他複雜性,例如反序列化的物件。
- Runbook 所需的啟動時間比 PowerShell Runbook 更久,因為其在執行之前必須進行編譯。
- 您只能使用
Start-AzAutomationRunbook Cmdlet,將 PowerShell runbook 包含為子 runbook。
- Runbook 無法在 Linux 混合式 Runbook Worker 上執行。
Python Runbook
Python Runbook 會在 Python 3.10 下編譯。 您可以直接使用 Azure 入口網站的文字編輯器來編輯 Runbook 的程式碼。 您也可以使用離線文字編輯器,並匯入 Runbook 到 Azure 自動化。 父產品不再支援 Python 2.7 和 Python 3.8,建議您在 Python 3.10 運行時間版本中建立 Runbook。
目前,除了巴西東南部和 Gov 雲端以外,所有公用區域中的雲端和混合式作業都支援 Python 3.10 運行時間版本。
優點
附註
匯入 Python 套件可能需要幾分鐘的時間。
- 使用強固的 Python 程式庫。
- 可以在 Azure 中或在混合式 Runbook 背景工作角色上執行。
- 如果程式碼與不同版本相容,來自任何 3.x 版本的指令碼和套件可能得以運作。
- 針對 Windows 機器上的 Python 3.10 混合式作業,您可以選擇安裝您想要使用的任何 3.x 版本。
- 針對 Linux 電腦上的 Python 3.10 混合式作業工作,我們依賴電腦上安裝的 Python 3 版本來執行 DSC OMSConfig 和 Linux 混合式工作代理程式。 如果 Python 3 版本之間未發生方法簽章或合約的重大變更,則不同的版本應該得以運作。
限制
Python Runbook 的限制如下:
- 針對 Python 3.10 模組,目前僅支援以 cp310 Linux OS 為目標的轉輪檔案。
深入了解
- 不支援原始程式碼控制整合。
- Python 3.10 的自定義套件只會在作業運行時間期間進行驗證。 如果套件在執行階段中不相容,或套件的必要相依性未匯入自動化帳戶,則預期作業會失敗。
- 目前,只有 Azure 入口網站和 Rest API 才支援 Python 3.10 Runbook。
- 父產品 Python 不再支援 Python 3.8。 建議您使用支援的版本建立新的 Runbook,以更新過期的 Runbook。
- 必須熟悉 Python 指令碼。
- 不支援原始程式碼控制整合。
- 針對 Python 3.8 模組,請使用專為 cp38-amd64 設計的 wheel 檔案。
- 若要使用第三方程式庫,您必須匯入套件至自動化帳戶。
- 無法在 PowerShell/PowerShell 工作流程中使用 Start-AutomationRunbook Cmdlet 來啟動 Python 3.8 Runbook。 您可以從 Az.Automation 模組使用 Start-AzAutomationRunbook Cmdlet 或來自 AzureRm.Automation 模組的 Start-AzureRmAutomationRunbook Cmdlet 來解決這項限制。
- Azure 自動化不支援 sys.stderr。
- Python automationassets 套件不適用於 pypi.org,因此無法匯入至 Windows 機器。
- 父產品 Python 不再支援 Python 2.7。 建議您使用支援的版本建立新的 Runbook,以更新過期的 Runbook。
- 必須熟悉 Python 指令碼。
- 針對 Python 2.7.12 模組,請使用 wheel 檔案 cp27-amd6。
- 若要使用第三方程式庫,您必須匯入套件至自動化帳戶。
- Azure 自動化不支援 sys.stderr。
- Python automationassets 套件不適用於 pypi.org,因此無法匯入至 Windows 機器。
附註
不支援使用 Webhook 來啟動 Python Runbook。
多個 Python 版本
適用於 Windows 混合式員工。 針對 Windows Runbook 背景工作角色,在執行 Python 2 Runbook 時,會先尋找環境變數 PYTHON_2_PATH,並驗證此變數是否指向有效的可執行檔。 例如,如果安裝資料夾是 C:\Python2,此變數會檢查 C:\Python2\python.exe 是否為有效的路徑。 如果找不到,則會尋找 PATH 環境變數以執行類似的檢查。
針對 Python 3,會先尋找 PYTHON_3_PATH env 變數,然後再回復至 PATH 環境變數。
僅使用一個版本的 Python 時,您可以將安裝路徑新增至 PATH 變數。 如果您想要在 Runbook 背景工作器上使用這兩個版本,請將 PYTHON_2_PATH 和 PYTHON_3_PATH 設定為這些版本模組的位置。
已知問題
針對雲端作業,Python 3.8 作業有時會失敗,並顯示例外狀況訊息 invalid interpreter executable path。 如果作業延遲、啟動超過 10 分鐘,或使用 Start-AutomationRunbook 啟動 Python 3.8 Runbook,您可能會看到此例外狀況。 如果作業延遲,重新啟動 runbook 可能有效。
圖形化 Runbook
您可以使用 Azure 入口網站中的圖形化編輯器,建立和編輯圖形化和圖形化 PowerShell 工作流程 Runbook。 不過,您無法使用另一個工具來建立或編輯這種類型的 Runbook。 圖形化操作手冊的主要功能:
- 匯出至您自動化帳戶中的檔案,然後匯入至另一個自動化帳戶。
- 產生 PowerShell 程式碼。
- 在匯入期間轉換為圖形化 PowerShell 工作流程 Runbook,或從該 Runbook 進行轉換。
優點
- 使用視覺化的插入連結設定撰寫模型。
- 將焦點放在資料如何透過此程序來流動。
- 以視覺方式呈現管理程序。
- 包含其他 Runbook 做為子 Runbook 來建立高階工作流程。
- 建議您採用模組化的程式設計。
限制
- 無法在 Azure 入口網站外部建立或編輯。
- 可能需要包含 PowerShell 程式碼的程式碼活動來執行複雜邏輯。
- 無法轉換成其中一個文字格式,也無法將文字 Runbook 轉換成圖形格式。
- 無法檢視或直接編輯圖形化工作流程所建立的 PowerShell 程式碼。 您可以檢視您在任何程式碼活動中所建立的程式碼。
- 無法在 Linux 混合式 Runbook 背景工作角色上執行 Runbook。 請參閱使用混合式 Runbook 背景工作角色將資料中心或雲端中的資源自動化。
- 無法以數位方式簽署圖形化 Runbook。
下一步