Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

azure-arm-iothub

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

azure-arm-iothub

IotHubClient Library with typescript type definitions for node

  • 2.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Microsoft Azure SDK for Node.js - IoT Hub

This project provides a Node.js package that makes it easy to manage Microsoft Azure Iot Hub Resources.Right now it supports:

  • Node.js version: 6.x.x or higher

How to Install

npm install azure-arm-iothub

How to Use

Authentication, client creation and listing iotHubs in a subscription as an example


 var msRestAzure = require('ms-rest-azure');
 var IoTHubClient = require('azure-arm-iothub');

 // Interactive Login
 msRestAzure.interactiveLogin(function(err, credentials) 
   {
   var client = new IoTHubClient(credentials, 'your-subscription-id');
   client.iotHubResource.listBySubscription(function (err, result, request, response)
   {
     if (err)
     {
       console.log(err);
     }

     console.log(result);
   });
 });

Check if an IoT Hub name is available


  var operationInputs = 
  {
    name: resourceName
  };

  client.iotHubResource.checkNameAvailability(resourceName, operationInputs, function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  }

Create an IoT Hub


  var iotHubCreateParams =
  {
    name: resourceName,
    location: location,
    subscriptionid: subscriptionId,
    resourcegroup: resourceGroupName,
    sku:
    {
      name: 'S1',
      capacity: 2
    },
    properties:
    {
      enableFileUploadNotifications: false,
	  ipFilterRules: [
		 {
			filterName: "ipfilterrule",
			action: "accept",
			ipMask: "0.0.0.0/0"
		 }
		],
      operationsMonitoringProperties:
      {
        events:
        {
          "C2DCommands": "Error",
          "DeviceTelemetry": "Error",
          "DeviceIdentityOperations": "Error",
          "Connections": "Error, Information"
        }
      },
      "features": "None",
    }
  }

  client.iotHubResource.createOrUpdate(resourceGroupName, resourceName, iotHubCreateParams, function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  });

Update an IoT Hub


  var iotHubUpdateParams =
  {
    name: resourceName,
    location: location,
    subscriptionid: subscriptionId,
    resourcegroup: resourceGroupName,
    sku:
    {
      name: 'S1',
      capacity: 3
    },
    properties:
    {
      enableFileUploadNotifications: false,
      ipFilterRules: [
        {
           filterName: "ipfilterrule2",
           action: "reject",
           ipMask: "192.168.0.0/10"
        }
      ],
      operationsMonitoringProperties:
      {
        events:
        {
          "C2DCommands": "Error",
          "DeviceTelemetry": "Error",
          "DeviceIdentityOperations": "Error",
          "Connections": "Error, Information"
        }
      },
      "features": "None",
    }
  }

  client.iotHubResource.createOrUpdate(resourceGroupName, resourceName, iotHubUpdateParams, function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  });

Get an IoT Hub Description


  client.iotHubResource.get(resourceGroupName, resourceName, function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  });

Delete an IoT Hub


  client.iotHubResource.deleteMethod(resourceGroupName, resourceName, function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  });

Get all IoT Hub Descriptions in a resourcegroup


  client.iotHubResource.listByResourceGroup(resourceGroupName, function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  });

Get IoT Hub Quota Metrics


  client.iotHubResource.getQuotaMetrics(resourceGroupName, resourceName, function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  });

Get Valid IoT Hub Skus


  client.iotHubResource.getValidSkus(resourceGroupName, resourceName, function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  });

Get All IoT Hub Keys


  client.iotHubResource.listKeys(resourceGroupName, resourceName, function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  });

Get a specific IoT Hub Key


  client.iotHubResource.getKeysForKeyName(resourceGroupName, resourceName, 'iothubowner', function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  });

Get all eventhub consumer groups


  client.iotHubResource.listEventHubConsumerGroups(resourceGroupName, resourceName, 'events', function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  });

Add an eventhub consumer group


  client.iotHubResource.createEventHubConsumerGroup(resourceGroupName, resourceName, eventsEndpointName, consumerGroupName, function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  });

Get an eventhub consumer group


  client.iotHubResource.getEventHubConsumerGroup(resourceGroupName, resourceName, eventsEndpointName, consumerGroupName, function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  });

Delete an eventhub consumer group


  client.iotHubResource.deleteEventHubConsumerGroup(resourceGroupName, resourceName, eventsEndpointName, consumerGroupName, function (err, result, request, response)
  {
    if (err)
    {
      console.log(err);
    }

    console.log(result);
  });

  • Microsoft Azure SDK for Node.js - All-up

Keywords

FAQs

Package last updated on 27 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc