You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: This article tells how to manage Python 2 packages in Azure Automation.
4
4
services: automation
5
5
ms.subservice: process-automation
6
-
ms.date: 10/29/2021
6
+
ms.date: 08/21/2023
7
7
ms.topic: conceptual
8
8
ms.custom: devx-track-python
9
9
---
@@ -16,7 +16,7 @@ For information on managing Python 3 packages, see [Manage Python 3 packages](./
16
16
17
17
## Import packages
18
18
19
-
1. In your Automation account, select **Python packages** under **Shared Resources**. Click**+ Add a Python package**.
19
+
1. In your Automation account, select **Python packages** under **Shared Resources**. Select**+ Add a Python package**.
20
20
21
21
:::image type="content" source="media/python-packages/add-python-package.png" alt-text="Screenshot of the Python packages page shows Python packages in the left menu and Add a Python package highlighted.":::
22
22
@@ -26,13 +26,13 @@ For information on managing Python 3 packages, see [Manage Python 3 packages](./
26
26
27
27
:::image type="content" source="media/python-packages/upload-package.png" alt-text="Screenshot shows the Add Python Package page with an uploaded tar.gz file selected.":::
28
28
29
-
After a package has been imported, it's listed on the **Python packages** page in your Automation account. To remove a package, select the package and click**Delete**.
29
+
After a package has been imported, it's listed on the **Python packages** page in your Automation account. To remove a package, select the package and select**Delete**.
30
30
31
31
:::image type="content" source="media/python-packages/package-list.png" alt-text="Screenshot shows the Python 2.7.x packages page after a package has been imported.":::
32
32
33
33
## Import packages with dependencies
34
34
35
-
Azure automation doesn't resolve dependencies for Python packages during the import process. There are two ways to import a package with all its dependencies. Only one of the following steps needs to be used to import the packages into your Automation account.
35
+
Azure Automation doesn't resolve dependencies for Python packages during the import process. There are two ways to import a package with all its dependencies. Only one of the following steps needs to be used to import the packages into your Automation account.
36
36
37
37
### Manually download
38
38
@@ -46,7 +46,7 @@ Once the packages are downloaded, you can import them into your automation accou
46
46
47
47
### Runbook
48
48
49
-
To obtain a runbook, [import Python 2 packages from pypi into Azure Automation account](https://github.com/azureautomation/import-python-2-packages-from-pypi-into-azure-automation-account) from the Azure Automation GitHub organization into your Automation account. Make sure the Run Settings are set to **Azure** and start the runbook with the parameters. The runbook requires a Run As account for the Automation account to work. For each parameter make sure you start it with the switch as seen in the following list and image:
49
+
To obtain a runbook, [import Python 2 packages from pypi into Azure Automation account](https://github.com/azureautomation/import-python-2-packages-from-pypi-into-azure-automation-account) from the Azure Automation GitHub organization into your Automation account. Make sure the Run Settings are set to **Azure** and start the runbook with the parameters. Ensure that Managed identity is enabled for your Automation account and has Automation Contributor access for successful import of package. For each parameter make sure you start it with the switch as seen in the following list and image:
50
50
51
51
* -s \<subscriptionId\>
52
52
* -g \<resourceGroup\>
@@ -55,41 +55,32 @@ Once the packages are downloaded, you can import them into your automation accou
55
55
56
56
:::image type="content" source="media/python-packages/import-python-runbook.png" alt-text="Screenshot shows the Overview page for import_py2package_from_pypi with the Start Runbook pane on the right side.":::
57
57
58
-
The runbook allows you to specify what package to download. For example, use of the `Azure` parameter downloads all Azure modules and all dependencies (about 105).
59
-
60
-
After the runbook is complete, you can check the **Python packages** under **Shared Resources** in your Automation account to verify that the package has been imported correctly.
58
+
The runbook allows you to specify what package to download. For example, use of the `Azure` parameter downloads all Azure modules and all dependencies (about 105). After the runbook is complete, you can check the **Python packages** under **Shared Resources** in your Automation account to verify that the package has been imported correctly.
61
59
62
60
## Use a package in a runbook
63
61
64
-
With a package imported, you can use it in a runbook. The following example uses the [Azure Automation utility package](https://github.com/azureautomation/azure_automation_utility). This package makes it easier to use Python with Azure Automation. To use the package, follow the instructions in the GitHub repository and add it to the runbook. For example, you can use `from azure_automation_utility import get_automation_runas_credential` to import the function for retrieving the Run As account.
62
+
With a package imported, you can use it in a runbook. Add the following code to list all the resource groups in an Azure subscription:
65
63
66
64
```python
67
-
import azure.mgmt.resource
68
-
import automationassets
69
-
from azure_automation_utility import get_automation_runas_credential
70
-
71
-
# Authenticate to Azure using the Azure Automation RunAs service principal
> The Python `automationassets` package is not available on pypi.org, so it's not available for import onto a Windows machine.
88
-
89
80
## Develop and test runbooks offline
90
81
91
82
To develop and test your Python 2 runbooks offline, you can use the [Azure Automation Python emulated assets](https://github.com/azureautomation/python_emulated_assets) module on GitHub. This module allows you to reference your shared resources such as credentials, variables, connections, and certificates.
92
83
93
84
## Next steps
94
85
95
-
To prepare a Python runbook, see [Create a Python runbook](./learn/automation-tutorial-runbook-textual-python-3.md).
86
+
To prepare a Python runbook, see [Create a Python runbook](./learn/automation-tutorial-runbook-textual-python-3.md).
0 commit comments