Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@azure/event-processor-host

Azure122MITdeprecated2.1.1TypeScript support: included

Please note, a newer package @azure/event-hubs is available as of January, 2020. While this package will continue to receive critical bug fixes, we strongly encourage you to upgrade.

Azure Event Processor Host (Event Hubs) SDK for JS.

azure, cloud, event hubs, event processor, events

readme

Azure SDK for JavaScript

Packages Dependencies DependencyGraph

This repository is for the Azure SDK for JavaScript (Node.js & Browser). It contains libraries for the breadth of Azure services. Management libraries are packages that you would use to provision and manage Azure resources. Client libraries are packages that you would use to consume these resources and interact with them.

Getting started

A few helpful resources to get started are:

  • The readme for each package contains code samples and package information. This readme can be found in the corresponding package folder under the folder of the service of your choice in the /sdk folder of this repository. The same readme file can be found on the landing page for the package in npm.
  • The API reference documentation of the latest versions of these packages, can be found at our public developer docs.
  • The API reference documentation of older versions, can be found in our versioned developer docs.

Each service might have a number of libraries available from each of the following categories:

NOTE: Some of these packages have beta versions. If you need to ensure your code is ready for production, use one of the stable, non-beta packages.

Client

Given an Azure resource already exists, you would use the client libraries to consume it and interact with it. Most of these libraries follow the Azure SDK Design Guidelines for JavaScript & TypeScript and share a number of core functionalities such as retries, logging, transport protocols, authentication protocols, etc. Others will be updated in the near future to follow the guidelines as well.

To get a list of all client libraries that follow the new guidelines, please visit our Azure SDK releases page.

Management

Management libraries enable you to provision and manage Azure resources via the Azure Resource Manager i.e. ARM. You can recognize these libraries by @azure/arm- in their package names. These are purely auto-generated based on the swagger files that represent the APIs for resource management.

Newer versions of these libraries follow the Azure SDK Design Guidelines for TypeScript. These new versions provide a number of core capabilities that are shared amongst all Azure SDKs, including the intuitive Azure Identity library, an HTTP Pipeline with custom policies, error-handling, distributed tracing, and much more. A few helpful resources to get started with these are:

NOTE: If you are experiencing authentication issues with the management libraries after upgrading certain packages, it's possible that you upgraded to the new versions of SDK without changing the authentication code, please refer to the migration guide mentioned above for proper instructions.

Need help?

Data Collection

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described below. You can learn more about data collection and use in the help documentation and Microsoft’s privacy statement. For more information on the data collected by the Azure SDK, please visit the Telemetry Guidelines page.

Telemetry Configuration

Telemetry collection is on by default.

To opt out, you can disable telemetry at client construction. Create a custom HTTP pipeline policy that removes the user agent string, and then pass that policy into the additionalPolicies option during client creation. This will disable telemetry for all methods in the client. Do this for every new client.

The example below uses the @azure/keyvault-secrets package. In your code, you can replace @azure/keyvault-secrets with the package you are using.

import { SecretClient } from "@azure/keyvault-secrets";
import { ManagedIdentityCredential } from "@azure/identity";

function removeUserAgentPolicy() {
  return {
    name: "removeUserAgentPolicy",
    sendRequest(request, next) {
      request.headers.delete("User-Agent");
      return next(request);
    },
  };
}

/**
 * Creates a SecretClient with managed identity authentication and empty user agent
 * @param keyvaultUri - The URI of the Azure Key Vault
 * @returns configured SecretClient instance
 */
function createSecretClientWithManagedIdentity(
  keyvaultUri: string
): SecretClient {
  // Create ManagedIdentityCredential for managed identity authentication
  const credential = new ManagedIdentityCredential();

  // Create secret client with managed identity and empty user agent
  const secretClient = new SecretClient(keyvaultUri, credential, {
    additionalPolicies: [
      {
        position: "perCall",
        policy: removeUserAgentPolicy(),
      },
    ],
  });

  return secretClient;
}

// Usage example
const keyvaultUri = "https://your-keyvault-name.vault.azure.net";
const secretClient = createSecretClientWithManagedIdentity(keyvaultUri);

// Now you can use the secret client to perform operations
// For example:
// const secretValue = await secretClient.getSecret("your-secret-name");

Community

Try our community resources.

Reporting security issues and security bugs

Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) secure@microsoft.com. You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the MSRC PGP key, can be found in the Security TechCenter.

Contributing

For details on contributing to this repository, see the contributing guide.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

changelog

2.1.1

  • Updates minimum version of @azure/event-hubs from version 2.1.1 to version 2.1.4. This update brings in improvements when attempting to reconnect after a transient failure. See the changelog for @azure/event-hubs for a full list of the improvements since version 2.1.1.

2019-08-06 2.1.0

  • Added support for WebSockets. WebSockets enable Event processor Host to work over an HTTP proxy and in environments where the standard AMQP port 5671 is blocked. Refer to the websockets sample to see how to use WebSockets.
  • Fixed bug 4363 which stopped users from providing their own LeaseManager. If both a lease manager and the options for leaseDuration/leaseRenewInterval are provided, then the latter will be ignored in favor of the leaseDuration/leaseRenewInterval properties on the lease manager.

2019-07-16 2.0.0

  • Use the latest version of the dependency on @azure/event-hubs that has the following bug fixes
    • Added event handlers for error and protocolError events on the connection object to avoid the case of unhandled exceptions. This is related to the bug 4136
    • A network connection lost error is now treated as retryable error. A new error with name ConnectionLostError is introduced for this scenario which you can see if you enable the logs.
    • When recovering from an error that caused the underlying AMQP connection to get disconnected, rhea reconnects all the older AMQP links on the connection resulting in the below 2 errors in the logs. We now clear rhea's internal map to avoid such reconnections. We already have code in place to create new AMQP links to resume send/receive operations.
      • InvalidOperationError: A link to connection '.....' $cbs node has already been opened.
      • UnauthorizedError: Unauthorized access. 'Listen' claim(s) are required to perform this operation.

Breaking Changes

  • If you have been using the createFromAadTokenCredentials function or the createFromAadTokenCredentialsWithCustomCheckpointAndLeaseManager function to create an instance of the EventProcessorHost, you will now need to use the @azure/ms-rest-nodeauth library instead of ms-rest-azure library to create the credentials that are needed by these functions. - Typescript: Replace import * from "ms-rest-azure"; with import * from "@azure/ms-rest-nodeauth"; - Javascript: Replace require("ms-rest-azure") with require("@azure/ms-rest-nodeauth")

2018-10-05 1.0.6

  • Remove @azure/amqp-common and rhea-promise as dependencies, since we use very little from those libraries and there is a risk of having two instances of rhea in the dependency chain which can cause problems while encoding types for filters.
  • HostContext.connectionConfig is now of type EventHubConnectionConfig.
  • Minimum dependency on @azure/event-hubs: "^1.0.6".

2018-10-01 1.0.5

  • Bumping minimum version of @azure/event-hubs to "1.0.5".
  • Taking a dependency on "@azure/amqp-common" for reusing the common parts.

2018-09-25 1.0.4

  • Bumping minimum version of @azure/event-hubs to "1.0.4".

2018-09-25 1.0.3

  • Ensures that amqp:link-stolen errors are not notified to the customer, since they are expected errors that happen during lease stealing or expiration as a part of load balancing.

2018-09-15 1.0.2

  • Ensures that messages are checkpointed in order.

2018-09-14 1.0.1

  • eph.getPartitionInformation() should works as expected when partitionId is of type number | string.
  • updated documentation for eventHubPath optional property in the FromConnectionStringOptions object.

2018-09-12 1.0.0

  • Stable version of the library.

2018-09-12 0.2.0

  • Added support to automatically balance the load of receiving messages across multiple partitions.
  • Added static method to create an EPH from an IotHubConnectionString
  • Added user-agent to the underlying amqp-connection. This would help in tracking usage of EPH.
  • Changed the overall design of EPH.
  • Instead of attaching handlers on eph:message and eph:error, now the handlers need to be passed as arguments to the start() method on EPH.
  • Apart from that an additional handler/method can be passed as an optional property onEphError to EPH. This handler will receive notifications from EPH regarding any errors that occur during partition management.
  • Removed optional property leasecontainerName and replaced it with a required parameter storageContainerName wherever applicable in all the static methods on EventProcessorHost.
  • Removed optional property autoCheckpoint and added optional properties
    • checkpointManager
    • onEphError
    • leaseRenewInterval
    • leaseDuration
  • Please take a look at the examples for more details.

2018-07-16 0.1.4

  • Added an option autoCheckpoint: false to not checkpoint the received messages by default.

2018-06-13 0.1.3

  • _storageBlobPrefix is set if provided in the options, #91.

2018-06-13 0.1.2

  • Fixed an issue reported in #80.

2018-05-02 0.1.1

  • Fix dependency version.

2018-05-02 0.1.0

  • First version of azure-event-processor-host based on the new azure-event-hubs sdk.
  • This client library makes it easier to manage receivers for an EventHub.
  • You can checkpoint the received data to an Azure Storage Blob. The processor does checkpointing on your behalf at regular intervals. This makes it easy to start receiving events from the point you left at a later time.