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
Copy file name to clipboardExpand all lines: articles/automation/automation-connections.md
+58-29Lines changed: 58 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,47 +9,52 @@ ms.topic: conceptual
9
9
10
10
# Manage connections in Azure Automation
11
11
12
-
An Automation connection asset contains the information required to connect to an external service or application from a runbook or DSC configuration. This may include information required for authentication such as a username and password in addition to connection information such as a URL or a port. The value of a connection is keeping all of the properties for connecting to a particular application in one asset as opposed to creating multiple variables. The user can edit the values for a connection in one place, and you can pass the name of a connection to a runbook or DSC configuration in a single parameter. The properties for a connection can be accessed in the runbook or DSC configuration with the `Get-AutomationConnection` activity.
12
+
An Azure Automation connection asset contains the information listed below. This information is required for connection to an external service or application from a runbook or DSC configuration.
13
13
14
-
When you create a connection, you must specify a connection type. The connection type is a template that defines a set of properties. The connection defines values for each property defined in its connection type. Connection types are added to Azure Automation in integration modules or created with the [Azure Automation API](/previous-versions/azure/reference/mt163818(v=azure.100)) if the integration module includes a connection type and is imported into your Automation account. Otherwise, you must create a metadata file to specify an Automation connection type. For more information regarding this, see [Integration Modules](automation-integration-modules.md).
14
+
* Information needed for authentication, such as user name and password
15
+
* Connection information, such as URL or port
16
+
17
+
The connection asset keeps all properties for connecting to a particular application together, making it unnecessary to create multiple variables. You can edit the values for a connection in one place, and you can pass the name of a connection to a runbook or DSC configuration in a single parameter. The runbook or configuration accesses the properties for a connection using the internal `Get-AutomationConnection` cmdlet.
18
+
19
+
When you create a connection, you must specify a connection type. The connection type is a template that defines a set of properties. You can add a connection type to Azure Automation using an integration module with a metadata file. It's also possible to create a connection type using the [Azure Automation API](/previous-versions/azure/reference/mt163818(v=azure.100)) if the integration module includes a connection type and is imported into your Automation account.
15
20
16
21
>[!NOTE]
17
-
>Secure assets in Azure Automation include credentials, certificates, connections, and encrypted variables. These assets are encrypted and stored in Azure Automation using a unique key that is generated for each Automation account. This key is stored in a systemmanaged Key Vault. Before storing a secure asset, the key is loaded from Key Vault and then used to encrypt the asset. This process is managed by Azure Automation.
22
+
>Secure assets in Azure Automation include credentials, certificates, connections, and encrypted variables. These assets are encrypted and stored in Azure Automation using a unique key that is generated for each Automation account. Azure Automation stores the key in the system-managed Key Vault. Before storing a secure asset, Automation loads the key from Key Vault and then uses it to encrypt the asset.
18
23
19
24
>[!NOTE]
20
25
>This article has been updated to use the new Azure PowerShell Az module. You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. To learn more about the new Az module and AzureRM compatibility, see [Introducing the new Azure PowerShell Az module](https://docs.microsoft.com/powershell/azure/new-azureps-module-az?view=azps-3.5.0). For Az module installation instructions on your Hybrid Runbook Worker, see [Install the Azure PowerShell Module](https://docs.microsoft.com/powershell/azure/install-az-ps?view=azps-3.5.0). For your Automation account, you can update your modules to the latest version using [How to update Azure PowerShell modules in Azure Automation](automation-update-azure-modules.md).
21
26
22
27
## Connection types
23
28
24
-
There are three types of built-in connections available in Azure Automation:
29
+
Azure Automation makes the following built-in connections available:
25
30
26
-
***Azure** - This connection can be used to manage classic resources.
27
-
***AzureClassicCertificate** - This connection is used by the **AzureClassicRunAs** account.
28
-
***AzureServicePrincipal** - This connection is used by the **AzureRunAs** account.
31
+
*`Azure` - This connection can be used to manage classic resources.
32
+
*`AzureServicePrincipal` - This connection is used by the Azure Run As account.
33
+
*`AzureClassicCertificate` - This connection is used by the classic Azure Run As account.
29
34
30
35
In most cases, you don't need to create a connection resource because it is created when you create a [Run As account](manage-runas-account.md).
31
36
32
37
## Windows PowerShell cmdlets
33
38
34
-
The cmdlets in the following table are used to create and manage Automation connections with Windows PowerShell. They ship as part of the [Azure PowerShell module](/powershell/azure/overview), which is available for use in Automation runbooks and DSC configurations.
39
+
The cmdlets in the following table are used to create and manage Automation connections with Windows PowerShell. They ship as part of the Az module. See [Manage modules in Azure Automation](shared-resources/modules.md).
35
40
36
41
|Cmdlet|Description|
37
42
|---|---|
38
-
|[Get-AzAutomationConnection](https://docs.microsoft.com/powershell/module/az.automation/get-azautomationconnection?view=azps-3.7.0)|Retrieves a connection. Includes a hashtable with the values of the connection fields.|
43
+
|[Get-AzAutomationConnection](https://docs.microsoft.com/powershell/module/az.automation/get-azautomationconnection?view=azps-3.7.0)|Retrieves information about a connection.|
39
44
|[New-AzAutomationConnection](https://docs.microsoft.com/powershell/module/az.automation/new-azautomationconnection?view=azps-3.7.0)|Creates a new connection.|
40
45
|[Remove-AzAutomationConnection](https://docs.microsoft.com/powershell/module/Az.Automation/Remove-AzAutomationConnection?view=azps-3.7.0)|Removes an existing connection.|
41
46
|[Set-AzAutomationConnectionFieldValue](https://docs.microsoft.com/powershell/module/Az.Automation/Set-AzAutomationConnectionFieldValue?view=azps-3.7.0)|Sets the value of a particular field for an existing connection.|
42
47
43
-
## Activities
48
+
## Internal cmdlets
44
49
45
-
The activities in the following table are used to access connections in a runbook or DSC configuration.
50
+
The internal cmdlet in the following table is used to access connections in your runbooks and DSC configurations. This cmdlet comes with the global module `Orchestrator.AssetManagement.Cmdlets`. For more information, see [Internal cmdlets](shared-resources/modules.md#internal-cmdlets).
46
51
47
-
|Activities|Description|
52
+
|Internal Cmdlet|Description|
48
53
|---|---|
49
-
|`Get-AutomationConnection`|Gets a connection to use. Returns a hashtablewith the properties of the connection.|
54
+
|`Get-AutomationConnection`|Retrieves the values of the different fields in the connection and returns them as a [hashtable](https://go.microsoft.com/fwlink/?LinkID=324844). This hashtable can then be used with the appropriate commands in the runbook or DSC configuration.|
50
55
51
56
>[!NOTE]
52
-
>Avoid using variables with the `Name` parameter of `Get-AutomationConnection`. Use of this parameter can complicate discovery of dependencies between runbooks or DSC configurations, and connection assets at design time.
57
+
>Avoid using variables with the `Name` parameter of `Get-AutomationConnection`. Use of this parameter can complicate discovery of dependencies between runbooks or DSC configurations and connection assets at design time.
53
58
54
59
## Python 2 functions
55
60
@@ -66,15 +71,16 @@ The function in the following table is used to access connections in a Python 2
66
71
67
72
### Create a new connection with the Azure portal
68
73
69
-
1. From your Automation account, click the **Assets** part to open the **Assets** blade.
70
-
2. Click the **Connections** part to open the **Connections** blade.
71
-
3. Click **Add a connection** at the top of the blade.
72
-
4. In the **Type** dropdown, select the type of connection you want to create. The form will present the properties for that particular type.
73
-
5. Complete the form and click **Create** to save the new connection.
74
+
To create a new connection in the Azure portal:
75
+
76
+
1. From your Automation account, click **Connections** under **Shared Resources**.
77
+
2. Click **+ Add a connection** on the Connections page.
78
+
4. In the **Type** field on the New Connection pane, select the type of connection to create. Your choices are `Azure`, `AzureServicePrincipal`, and `AzureClassicCertificate`.
79
+
5. The form presents properties for the connection type that you've chosen. Complete the form and click **Create** to save the new connection.
74
80
75
81
### Create a new connection with Windows PowerShell
76
82
77
-
Create a new connection with Windows PowerShell using the `New-AzAutomationConnection` cmdlet. This cmdlet has a parameter named `ConnectionFieldValues` that expects a [hashtable](https://technet.microsoft.com/library/hh847780.aspx) defining values for each of the properties defined by the connection type.
83
+
Create a new connection with Windows PowerShell using the `New-AzAutomationConnection` cmdlet. This cmdlet has a `ConnectionFieldValues`parameter that expects a hashtable defining values for each of the properties defined by the connection type.
78
84
79
85
You can use the following example commands as an alternative to creating the Run As account from the portal to create a new connection asset.
When you create your Automation account, it includes several global modules by default, along with the connection type `AzureServicePrincipal` to create the `AzureRunAsConnection` connection asset. If you try to create a new connection asset to connect to a service or application with a different authentication method, the operation fails because the connection type is not already defined in your Automation account. For more information on creating your own connection type for a custom [PowerShell Gallery](https://www.powershellgallery.com) module, see [Integration modules](automation-integration-modules.md).
93
+
When you create your Automation account, it includes several global modules by default, along with the connection type `AzureServicePrincipal` to create the `AzureRunAsConnection` connection asset. If you try to create a new connection asset to connect to a service or application with a different authentication method, the operation fails because the connection type is not already defined in your Automation account. For more information on creating your own connection type for a custom module, see [Adding a connection type](#adding-a-connection-type).
94
+
95
+
## Adding a connection type
96
+
97
+
If your runbook or DSC configuration connects to an external service, you must define a connection type in a [custom module](shared-resources/modules.md#custom-modules), called an integration module. This file specifies connection type properties and is named **<ModuleName>-Automation.json**, located in the module folder of your compressed **.zip** file. This file contains the fields of a connection that are required to connect to the system or service the module represents. Using this file, you can set the field names, data types, encryption status, and optional status for the connection type.
98
+
99
+
The following example is a template in the **.json** file format that defines user name and password properties for a custom connection type:
100
+
101
+
```json
102
+
{
103
+
"ConnectionFields": [
104
+
{
105
+
"IsEncrypted": false,
106
+
"IsOptional": true,
107
+
"Name": "Username",
108
+
"TypeName": "System.String"
109
+
},
110
+
{
111
+
"IsEncrypted": true,
112
+
"IsOptional": false,
113
+
"Name": "Password",
114
+
"TypeName": "System.String"
115
+
}
116
+
],
117
+
"ConnectionTypeName": "MyModuleConnection",
118
+
"IntegrationModuleName": "MyModule"
119
+
}
120
+
```
88
121
89
122
## Using a connection in a runbook or DSC configuration
90
123
91
-
Retrieve a connection in a runbook or DSC configuration with the `Get-AutomationConnection` cmdlet. You can't use the `Get-AzAutomationConnection`activity. This activity retrieves the values of the different fields in the connection and returns them as a [hashtable](https://go.microsoft.com/fwlink/?LinkID=324844). This hashtable can then be used with the appropriate commands in the runbook or DSC configuration.
124
+
Retrieve a connection in a runbook or DSC configuration with the internal `Get-AutomationConnection` cmdlet. This cmdlet is preferred over the `Get-AzAutomationConnection`cmdlet. See [Internal cmdlets](shared-resources/modules.md#internal-cmdlets).
92
125
93
126
### Textual runbook sample
94
127
95
-
The following sample commands show how to use the Run As account mentioned earlier, to authenticate with Azure Resource Manager resources in your runbook. It uses the connection asset representing the Run As account, which references the certificate-based service principal, not credentials.
128
+
The following sample commands show how to use the Run As account to authenticate with Azure Resource Manager resources in your runbook. It uses the connection asset representing the Run As account, which references the certificate-based service principal.
> For non-graphical PowerShell runbooks, `Add-AzAccount` and `Add-AzureRMAccount` are aliases for [Connect-AzAccount](https://docs.microsoft.com/powershell/module/az.accounts/connect-azaccount?view=azps-3.5.0). You can use these cmdlets or you can [update your modules](automation-update-azure-modules.md) in your Automation account to the latest versions. You might need to update your modules even if you have just created a new Automation account.
104
-
105
135
### Graphical runbook samples
106
136
107
137
You add a `Get-AutomationConnection` activity to a graphical runbook by right-clicking on the connection in the Library pane of the graphical editor and selecting **Add to canvas**.
108
138
109
139

110
140
111
-
The following image shows an example of using a connection in a graphical runbook. This is the same example as shown above for authenticating using the Run As account with a textual runbook. This example uses the `Constant value` data set for the `Get RunAs Connection` activity that uses a connection object for authentication. A [pipeline link](automation-graphical-authoring-intro.md#links-and-workflow) is used here since the `ServicePrincipalCertificate` parameter set is expecting a single object.
141
+
The following image shows an example of using a connection in a graphical runbook. This example uses the `Constant value` data set for the `Get RunAs Connection` activity that uses a connection object for authentication. A [pipeline link](automation-graphical-authoring-intro.md#links-and-workflow) is used here since the `ServicePrincipalCertificate` parameter set is expecting a single object.
- Review [Links in graphical authoring](automation-graphical-authoring-intro.md#links-and-workflow) to understand how to direct and control the flow of logic in your runbooks.
163
193
* For a PowerShell cmdlet reference, see [Az.Automation](https://docs.microsoft.com/powershell/module/az.automation/?view=azps-3.7.0#automation
164
-
).
165
-
- To learn more about Azure Automation's use of PowerShell modules and best practices for creating your own PowerShell modules to work as Integration Modules within Azure Automation, see [Integration Modules](automation-integration-modules.md).
0 commit comments