|
| 1 | += Using Anypoint Studio to Configure Azure Event Hubs Connector 1.0 - Mule 4 |
| 2 | + |
| 3 | +Anypoint Studio (Studio) editors help you design and update your Mule applications, properties, and configuration files. |
| 4 | + |
| 5 | +To add and configure a connector in Studio: |
| 6 | + |
| 7 | +. <<create-mule-project,Create a Mule project>>. |
| 8 | +. <<add-connector-to-project,Add the connector to your Mule project>>. |
| 9 | +. <<configure-input-source,Configure a source for the connector's flow>>. |
| 10 | +. <<add-connector-operation,Add a connector operation to the flow>>. |
| 11 | +. <<configure-global-element,Configure a global element for the connector>>. |
| 12 | +. <<configure-other-fields,Configure the other connector fields>>. |
| 13 | + |
| 14 | +When you run the connector, you can view the app log to check for problems in real time, as described in <<view-app-log,View the App Log>>. |
| 15 | + |
| 16 | +If you are new to configuring connectors in Studio, see xref:connectors::introduction/intro-config-use-studio.adoc[Use Studio to Configure a Connector]. If, after reading this topic, you need additional information about the connector fields, refer to the xref:azure-event-hubs-connector-reference.adoc[Azure Event Hub Connector Reference]. |
| 17 | + |
| 18 | +[[create-mule-project]] |
| 19 | +== Create a Mule Project |
| 20 | + |
| 21 | +In Studio, create a new Mule project in which to add and configure the connector: |
| 22 | + |
| 23 | +. In Studio, select *File > New > Mule Project*. |
| 24 | +. Enter a name for your Mule project and click *Finish*. |
| 25 | + |
| 26 | +[[add-connector-to-project]] |
| 27 | +== Add the Connector to Your Mule Project |
| 28 | + |
| 29 | +Add Anypoint Connector for Azure Event Hubs Messaging (Azure Event Hubs Messaging Connector) to your Mule project to automatically populate the XML code with the connector's namespace and schema location and add the required dependencies to the project's `pom.xml` file: |
| 30 | + |
| 31 | +. In the *Mule Palette* view, click *(X) Search in Exchange*. |
| 32 | +. In the *Add Dependencies to Project* window, type `azure event hubs messaging` in the search field. |
| 33 | +. Click *Azure Event Hubs Connector* in *Available modules*. |
| 34 | +. Click *Add*. |
| 35 | +. Click *Finish*. |
| 36 | + |
| 37 | +Adding a connector to a Mule project in Studio does not make that connector available to other projects in your Studio workspace. |
| 38 | + |
| 39 | +[[configure-input-source]] |
| 40 | +== Configure a Source |
| 41 | + |
| 42 | +A source initiates a flow when a specified condition is met. |
| 43 | +You can configure one of these sources to use with Azure Event Hubs Connector: |
| 44 | + |
| 45 | +* HTTP Listener + |
| 46 | +Initiates a flow each time it receives a request on the configured host and port |
| 47 | +* Scheduler + |
| 48 | +Initiates a flow when a time-based condition is met |
| 49 | + |
| 50 | +For example, to configure an HTTP Listener source, follow these steps: |
| 51 | + |
| 52 | +. In the *Mule Palette* view, select *HTTP > Listener*. |
| 53 | +. Drag *Listener* to the Studio canvas. |
| 54 | +. On the *Listener* configuration screen, optionally change the value of the *Display Name* field. |
| 55 | +. Specify a value for the *Path* field. |
| 56 | +. Click the plus sign (*+*) next to the *Connector configuration* field to configure a global element that can be used by all instances of the HTTP Listener source in the app. |
| 57 | +. On the *General* tab, specify the connection information for the connector. |
| 58 | +. On the *TLS* tab, optionally specify the TLS information for the connector. |
| 59 | +. On the *Advanced* tab, optionally specify reconnection information, including a reconnection strategy. |
| 60 | +. Click *Test Connection* to confirm that Mule can connect with the specified server. |
| 61 | +. Click *OK*. |
| 62 | + |
| 63 | +[[add-connector-operation]] |
| 64 | +== Add a Connector Operation to the Flow |
| 65 | + |
| 66 | +When you add a connector operation to your flow, you are specifying an action for that connector to perform. |
| 67 | + |
| 68 | +To add an operation for Azure Event Hubs Messaging Connector, follow these steps: |
| 69 | + |
| 70 | +. In the *Mule Palette* view, select *Azure Event Hubs* and then select the desired operation. |
| 71 | +. Drag the operation onto the Studio canvas to the right of the source. |
| 72 | + |
| 73 | +[[configure-global-element]] |
| 74 | +== Configure a Global Element for the Connector |
| 75 | + |
| 76 | +When you configure a connector, configure a global element that all instances of that connector in the app can use. Configuring a global element requires you to provide the authentication that the connector requires to access the target Azure Event Hubs system. |
| 77 | +Azure Event Hubs Connector supports SAS authentication and Active Directory authentication. |
| 78 | + |
| 79 | +To configure the global element for Azure Event Hubs Connector, follow these steps: |
| 80 | + |
| 81 | +. Select the operation in the Studio canvas. |
| 82 | +. In the configuration screen for the operation, click the plus sign (*+*) next to the *Connector configuration* field to access the global element configuration fields. |
| 83 | +. On the *General* tab, in *Connection*, select the authentication method to configure: |
| 84 | + |
| 85 | +* <<config-sas, SAS authentication>> |
| 86 | +* <<config-active, Active Directory authentication>> |
| 87 | + |
| 88 | +[start=4] |
| 89 | +. On the *Advanced* tab, optionally specify reconnection information, including a reconnection strategy. |
| 90 | +. Click *Test Connection* to confirm that Mul runtime can connect with the specified server. |
| 91 | +. Click *OK*. |
| 92 | + |
| 93 | +[[config-sas]] |
| 94 | +=== Configure SAS Authentication |
| 95 | + |
| 96 | +Enter the following information on the *General* tab of the *Global Element Properties* screen to configure SAS authentication: |
| 97 | + |
| 98 | +[%header%autowidth.spread] |
| 99 | +|=== |
| 100 | +| Name | Type | Description | Default Value | Required |
| 101 | +| Namespace a| String | Azure Event Hubs namespace name. | | x |
| 102 | +| Shared Access Key Name a| String | Shared access key provided by Azure. | | x |
| 103 | +| Shared Access Key a| String | Shared access key value provided by Azure. | | x |
| 104 | +| Event Hub Name a| String | Azure Event Hub name. | | x |
| 105 | +| Share Connection a| Boolean | Toggles the builder to use the same connection for producers or consumers. | false | |
| 106 | +| Checkpoint Store Type a| One of: |
| 107 | + |
| 108 | +* <<AzureBlobStorageSasAuthentication>> |
| 109 | +* <<AzureBlobStorageActiveDirectoryAuthentication>> | Selects the Azure Blob Storage connection. | | |
| 110 | +| Reconnection a| Reconnection | Configures a reconnection strategy to use when the connector operation fails to connect to an external server. | | |
| 111 | +|=== |
| 112 | + |
| 113 | +[[config-active]] |
| 114 | +=== Configure Active Directory Authentication |
| 115 | + |
| 116 | +Enter the following information on the *General* tab of the *Global Element Properties* screen to configure Active Directory authentication. |
| 117 | + |
| 118 | +Using this authentication type enables you to configure *Token Credential Properties* or *Use default credentials*. |
| 119 | + |
| 120 | +[%header%autowidth.spread] |
| 121 | +|=== |
| 122 | +| Name | Type | Description | Default Value | Required |
| 123 | +| Token Credential Properties a| <<TokenCredentialProperties>> | Acquires a token via service principal authentication. | | |
| 124 | +| Use Azure Default Credential a| Boolean | Use the DefaultAzureCredentials mechanism. | false | |
| 125 | +| Namespace a| String | Azure Event Hubs namespace name. | | x |
| 126 | +| Authority Host a| String | Specifies the Azure Active Directory host. Defaults to https://login.microsoftonline.com/ | | |
| 127 | +| Event Hub Name a| String | Event Hub name. | | x |
| 128 | +| Share Connection a| Boolean | Toggles the builder to use the same connection for producers or consumers. | false | |
| 129 | +| Checkpoint Store Type a| One of: |
| 130 | + |
| 131 | +* <<AzureBlobStorageSasAuthentication>> |
| 132 | +* <<AzureBlobStorageActiveDirectoryAuthentication>> | Select the checkpointing connection provider. | | |
| 133 | +| Reconnection a| Reconnection | Configures a reconnection strategy to use when a connector operation fails to connect to an external server. | | |
| 134 | +|=== |
| 135 | + |
| 136 | +[[AzureBlobStorageSasAuthentication]] |
| 137 | +=== Configure Azure Blob Storage SAS Authentication |
| 138 | + |
| 139 | +The following table shows the fields for configuring *Azure blob storage sas authentication*. |
| 140 | + |
| 141 | +[%header,cols="20s,25a,30a,15a,10a"] |
| 142 | +|=== |
| 143 | +| Field | Type | Description | Default Value | Required |
| 144 | +| Container Name a| String | Container name. | | x |
| 145 | +| Account Name a| String | Account name of the Azure account. | | x |
| 146 | +| Account Key a| String | Account key of the Azure account. | | x |
| 147 | +|=== |
| 148 | + |
| 149 | +[[AzureBlobStorageActiveDirectoryAuthentication]] |
| 150 | +=== Configure Azure Blob Storage Active Directory Authentication |
| 151 | + |
| 152 | +The following table shows the fields to configure *Azure blob storage active directory authentication*. |
| 153 | + |
| 154 | +[%header,cols="20s,25a,30a,15a,10a"] |
| 155 | +|=== |
| 156 | +| Field | Type | Description | Default Value | Required |
| 157 | +| Token Credential Properties a| <<TokenCredentialProperties>> | Acquires a token via service principal authentication. | | |
| 158 | +| Use Azure Default Credential a| Boolean | If you set this flag to `true`, DefaultAzureCredential Class(Azure.Identity) is created to get a token to authenticate. | false | |
| 159 | +| Container Name a| String | Container name. | | x |
| 160 | +| Account Name a| String | Account name of the Azure account. | | x |
| 161 | +| Authority Host a| String |Specifies the Azure active directory host. Defaults to https://login.microsoftonline.com/ | | |
| 162 | +|=== |
| 163 | + |
| 164 | +[[TokenCredentialProperties]] |
| 165 | +=== Configure Token Credential Properties |
| 166 | + |
| 167 | +The following table shows the fields for configuring *Token credentials properties*. |
| 168 | + |
| 169 | +[%header,cols="20s,25a,30a,15a,10a"] |
| 170 | +|=== |
| 171 | +| Field | Type | Description | Default Value | Required |
| 172 | +| Tenant Id a| String | Tenant ID. | | |
| 173 | +| Client Id a| String | Client ID. | | |
| 174 | +| Client Secret a| String | Client secret. | | |
| 175 | +|=== |
| 176 | + |
| 177 | +=== Configuration Examples |
| 178 | + |
| 179 | +The following example shows the configuration for *Sas Authentication* with *Azure blob storage sas authentication* in Studio: |
| 180 | + |
| 181 | +image::aeh-sas.png[Configuring azure blob storage SAS authentication] |
| 182 | + |
| 183 | +In the *Configuration XML* editor, the `azure-eventhubs:sas-authentication-connection` and `azure-eventhubs:azure-blob-storage-sas-authentication` configurations look like this: |
| 184 | + |
| 185 | +[source,xml,linenums] |
| 186 | +---- |
| 187 | + <azure-eventhubs:azure-eventhubs-config name="sas" doc:name="Azure Event Hubs Connector Azure Event Hubs" > |
| 188 | + <azure-eventhubs:sas-authentication-connection namespace="${config.namespace}" sharedAccessKeyName="${sas-config.sharedAccessKeyName}" sharedAccessKey="${sas-config.sharedAccessKey}" eventHubName="${config.eventHuName}" > |
| 189 | + <azure-eventhubs:checkpoint-store-type > |
| 190 | + <azure-eventhubs:azure-blob-storage-sas-authentication containerName="${bs-config.containerName}" accountName="${bs-config.accountName}" accountKey="${bs-config.accountKey}" /> |
| 191 | + </azure-eventhubs:checkpoint-store-type> |
| 192 | + </azure-eventhubs:sas-authentication-connection> |
| 193 | + </azure-eventhubs:azure-eventhubs-config> |
| 194 | +---- |
| 195 | + |
| 196 | +The following example shows the configuration for *Active directory authentication* with *Azure blob storage sas authentication* and *Token credentials properties* in Studio: |
| 197 | + |
| 198 | +image::aeh-active-directory-client.png[Configuring active directory authentication with client credentials] |
| 199 | + |
| 200 | +In the *Configuration XML* editor, the `azure-eventhubs:active-directory-authentication-connection`, `azure-eventhubs:azure-blob-storage-sas-authentication`, and `azure-eventhubs:token-credential-properties` configurations look like this: |
| 201 | + |
| 202 | +[source,xml,linenums] |
| 203 | +---- |
| 204 | +<azure-eventhubs:azure-eventhubs-config name="ActiveDirectory" doc:name="Azure Event Hubs Connector Azure Event Hubs" > |
| 205 | + <azure-eventhubs:active-directory-authentication-connection namespace="${config.namespace}" eventHubName="${config.eventHubName}" > |
| 206 | + <azure-eventhubs:token-credential-properties tenantId="${ad-config.tenantId}" clientId="${ad-config.clientId}" clientSecret="${ad-config.clientSecret}" /> |
| 207 | + <azure-eventhubs:checkpoint-store-type > |
| 208 | + <azure-eventhubs:azure-blob-storage-sas-authentication containerName="${bs.config.containerName}" accountName="${bs.config.accountName}" accountKey="${bs.config.containerName}" /> |
| 209 | + </azure-eventhubs:checkpoint-store-type> |
| 210 | + </azure-eventhubs:active-directory-authentication-connection> |
| 211 | + </azure-eventhubs:azure-eventhubs-config> |
| 212 | +---- |
| 213 | + |
| 214 | +The following example shows the configuration for *Active directory authentication* with *Azure blob storage active directory authentication* and *Use azure default credentials* in Studio: |
| 215 | + |
| 216 | +image::aeh-active-directory-default-client.png[Configuring active directory authentication with default client credentials] |
| 217 | + |
| 218 | +In the *Configuration XML* editor, the `azure-eventhubs:active-directory-authentication-connection`, `azure-eventhubs:azure-blob-storage-sas-authentication` , and `useAzureDefaultCredential` configurations look like this: |
| 219 | + |
| 220 | +[source,xml,linenums] |
| 221 | +---- |
| 222 | +<azure-eventhubs:azure-eventhubs-config name="ActiveDirectory" doc:name="Azure Event Hubs Connector Azure Event Hubs" > |
| 223 | + <azure-eventhubs:active-directory-authentication-connection namespace="${config.namespace}" eventHubName="${config.eventHubName}" useAzureDefaultCredential="true"> |
| 224 | + <azure-eventhubs:checkpoint-store-type > |
| 225 | + <azure-eventhubs:azure-blob-storage-active-directory-authentication containerName="${bs-config.containerName}" accountName="${bs-config.accountName}" > |
| 226 | + <azure-eventhubs:token-credential-properties tenantId="${ad-config.tenantId}" clientId="${ad-config.clientId}" clientSecret="${ad-config.clientSecret}" /> |
| 227 | + </azure-eventhubs:azure-blob-storage-active-directory-authentication> |
| 228 | + </azure-eventhubs:checkpoint-store-type> |
| 229 | + </azure-eventhubs:active-directory-authentication-connection> |
| 230 | + </azure-eventhubs:azure-eventhubs-config> |
| 231 | +---- |
| 232 | + |
| 233 | +[[configure-other-fields]] |
| 234 | +== Configure Additional Connector Fields |
| 235 | + |
| 236 | +After you configure a global element for Azure Event Hubs Connector, configure the other required fields for the connector. The required fields vary depending on which connector operation you use. |
| 237 | + |
| 238 | +[[view-app-log]] |
| 239 | +== View the App Log |
| 240 | + |
| 241 | +To check for problems, you can view the app log as follows: |
| 242 | + |
| 243 | +* If you’re running the app from Anypoint Platform, the app log output is visible in the Anypoint Studio console window. |
| 244 | +* If you’re running the app using Mule from the command line, the app log output is visible in your OS console. |
| 245 | + |
| 246 | +Unless the log file path is customized in the app’s log file (`log4j2.xml`), you can also view the app log in the default location `MULE_HOME/logs/<app-name>.log`. |
| 247 | + |
| 248 | +== See Also |
| 249 | + |
| 250 | +* xref:connectors::introduction/introduction-to-anypoint-connectors.adoc[Introduction to Anypoint Connectors] |
| 251 | +* xref:connectors::introduction/intro-config-use-studio.adoc[Use Studio to Configure a Connector] |
| 252 | +* xref:azure-event-hubs-connector-reference.adoc[Azure Event Hubs Messaging Reference] |
| 253 | +* https://help.mulesoft.com[MuleSoft Help Center] |
0 commit comments