npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@airhornjs/azure

v6.0.1

Published

Azure provider for Airhorn

Readme

Airhorn


tests codecov license npm npm

@airhornjs/azure

Azure Communication Services and Notification Hubs provider for Airhorn.

Installation

npm install airhorn @airhornjs/azure

Features

  • SMS sending via Azure Communication Services
  • Email sending via Azure Communication Services
  • Mobile push notifications to iOS and Android devices via Azure Notification Hubs
  • Automatic error handling and retry support
  • Integration with Airhorn's notification system
  • Support for multiple connection strings

Usage

SMS with Azure Communication Services

import { Airhorn } from 'airhorn';
import { AirhornAzure } from '@airhornjs/azure';

// Create Azure provider for SMS
const azureProvider = new AirhornAzure({
  connectionString: 'endpoint=https://your-service.communication.azure.com/;accesskey=your-key',
});

// Create Airhorn instance with Azure provider
const airhorn = new Airhorn({
  providers: [azureProvider],
});

const data = {
  orderId: '12345',
  customerName: 'John',
};

// Send SMS
const template = {
  from: '+1234567890', // Your sender phone number (must be provisioned in Azure)
  content: 'Hello <%= customerName %>!, your order #<%= orderId %> has been shipped!',
  type: AirhornSendType.SMS,
};

const result = await airhorn.send(
  '+0987654321', // to
  template,
  data,
  AirhornSendType.SMS
);

Email with Azure Communication Services

import { Airhorn } from 'airhorn';
import { AirhornAzure } from '@airhornjs/azure';

// Create Azure provider with email support
const azureProvider = new AirhornAzure({
  connectionString: 'endpoint=https://your-service.communication.azure.com/;accesskey=your-key',
});

// Create Airhorn instance
const airhorn = new Airhorn({
  providers: [azureProvider],
});

const data = {
  orderId: '656565',
  customerName: 'John',
};

// Send Email
const template = {
  from: '[email protected]', // Must be verified domain in Azure
  subject: 'Order Confirmation: <%= orderId %>',
  content: 'Hi <%= customerName %>, your order #<%= orderId %> has been confirmed!',
};

const result = await airhorn.send(
  '[email protected]', // to
  template,
  data,
  AirhornSendType.Email
);

Mobile Push Notifications with Azure Notification Hubs

import { Airhorn } from 'airhorn';
import { AirhornAzure } from '@airhornjs/azure';

const azureProvider = new AirhornAzure({
  notificationHubConnectionString: 'Endpoint=sb://your-namespace.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=your-key',
  notificationHubName: 'your-hub-name',
});

const airhorn = new Airhorn({
  providers: [azureProvider],
});

const data = {
  orderId: '12345',
  customerName: 'John',
};

// Send to iOS device via APNs
const template = {
  from: 'YourApp',
  content: JSON.stringify({
    aps: {
      alert: {
        title: 'New Order',
        body: 'Hi <%= customerName %>You have a new order #<%= orderId %>',
      },
      badge: 1,
      sound: 'default',
    },
    // Custom data
    orderId: '12345',
  }),
};

// Send using tag expression
await airhorn.send(
  'user:john-doe', // Tag expression
  template,
  data,
  AirhornSendType.MobilePush,
  {
    platform: 'apple',
    tags: 'user:john-doe && ios',
  },
);

Custom Capabilities

You can specify which services to enable using the capabilities option:

// SMS only
const smsProvider = new AirhornAzure({
  connectionString: 'your-connection-string',
  capabilities: [AirhornSendType.SMS],
});

// Email only
const emailProvider = new AirhornAzure({
  connectionString: 'your-connection-string',
  capabilities: [AirhornSendType.Email],
});

// Mobile Push only
const pushProvider = new AirhornAzure({
  notificationHubConnectionString: 'your-hub-connection-string',
  notificationHubName: 'your-hub-name',
  capabilities: [AirhornSendType.MobilePush],
});

// All capabilities (explicit)
const allProvider = new AirhornAzure({
  connectionString: 'your-communication-services-connection-string',
  notificationHubConnectionString: 'your-hub-connection-string',
  notificationHubName: 'your-hub-name',
  capabilities: [AirhornSendType.SMS, AirhornSendType.Email, AirhornSendType.MobilePush],
});

Configuration

AirhornAzureOptions

  • connectionString (optional): Azure Communication Services connection string (used for both SMS and Email if specific strings not provided)
  • emailConnectionString (optional): Specific connection string for Email service
  • smsConnectionString (optional): Specific connection string for SMS service
  • notificationHubConnectionString (optional): Azure Notification Hub connection string
  • notificationHubName (optional): Azure Notification Hub name
  • capabilities (optional): Array of AirhornSendType values to specify which services to enable (defaults to SMS, MobilePush, and Email)

Additional Options

SMS Options

await airhorn.send(to, message, {
  // Additional SMS options from Azure Communication Services
  deliveryReportTimeoutInSeconds: 300,
  tag: 'custom-tag',
});

Prerequisites

Azure Communication Services

  1. Create an Azure Communication Services resource in Azure Portal
  2. Get your connection string from the resource
  3. For SMS: Provision a phone number through the Azure Portal
  4. For Email: Verify your sending domain

Azure Notification Hubs

  1. Create a Notification Hub namespace and hub in Azure Portal
  2. Configure platform credentials (APNs for iOS, FCM for Android)
  3. Get your connection string and hub name
  4. Implement device registration in your mobile apps

Azure RBAC Permissions

Minimum required permissions for the service principal or managed identity:

For Communication Services:

  • Azure Communication Services Contributor role
  • Or specific permissions:
    • Microsoft.Communication/CommunicationServices/read
    • Microsoft.Communication/CommunicationServices/write

For Notification Hubs:

  • Azure Notification Hubs Contributor role
  • Or specific permissions:
    • Microsoft.NotificationHubs/Namespaces/NotificationHubs/read
    • Microsoft.NotificationHubs/Namespaces/NotificationHubs/write

Testing

pnpm test

How to Contribute

Now that you've set up your workspace, you're ready to contribute changes to the airhorn repository you can refer to the CONTRIBUTING guide. If you have any questions please feel free to ask by creating an issue and label it question.

Licensing and Copyright

This project is MIT License © Jared Wray