Next Perpendicular Moonlanding

    @azure-rest/iot-device-update
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.0-beta.1 • Public • Published

    Azure Device Update for IoT Hub Rest Client library for JavaScript

    The library provides access to the Device Update for IoT Hub service that enables customers to publish updates for their IoT devices to the cloud, and then deploy these updates to their devices (approve updates to groups of devices managed and provisioned in IoT Hub).

    Please rely heavily on the service's documentation and our REST client docs to use this library

    Key links:

    Getting started

    Currently supported environments

    • Node.js version 14.x.x or higher

    Prerequisites

    • Microsoft Azure Subscription: To call Microsoft Azure services, you need to create an Azure subscription
    • Device Update for IoT Hub instance
    • Azure IoT Hub instance

    Install the @azure-rest/iot-device-update package

    Install the Azure Iot Device Update client library for JavaScript with npm:

    npm install @azure-rest/iot-device-update

    Create and authenticate a DeviceUpdate

    To use an Azure Active Directory (AAD) token credential, provide an instance of the desired credential type obtained from the @azure/identity library.

    To authenticate with AAD, you must first npm install @azure/identity.

    After installation, you can choose which type of credential from @azure/identity to use. As an example, DefaultAzureCredential can be used to authenticate the client:

    Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET

    Use the returned token credential to authenticate the client:

    import DeviceUpdate from "@azure-rest/iot-device-update";
    import { DefaultAzureCredential } from "@azure/identity";
    const client = DeviceUpdate(
      "https://<my-instance-id>.api.adu.microsoft.com",
      new DefaultAzureCredential()
    );

    Key concepts

    REST Client

    This client is one of our REST clients. We highly recommend you read how to use a REST client here.

    Examples

    The following section shows you how to initialize and authenticate your client, then get all devices.

    import DeviceUpdate from "@azure-rest/iot-device-update";
    import { DefaultAzureCredential } from "@azure/identity";
    
    async function main() {
      console.log("== List devices ==");
      const client = DeviceUpdate(endpoint, new DefaultAzureCredential());
    
      const result = await client
        .path("/deviceupdate/{instanceId}/management/devices", instanceId)
        .get();
    
      console.log(result);
    }
    
    main().catch(console.error);

    Troubleshooting

    Logging

    Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the AZURE_LOG_LEVEL environment variable to info. Alternatively, logging can be enabled at runtime by calling setLogLevel in the @azure/logger:

    import { setLogLevel } from "@azure/logger";
    
    setLogLevel("info");

    For more detailed instructions on how to enable logs, you can look at the @azure/logger package docs.

    Next steps

    Contributing

    If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.

    Related projects

    Impressions

    Install

    npm i @azure-rest/iot-device-update

    DownloadsWeekly Downloads

    94

    Version

    1.0.0-beta.1

    License

    MIT

    Unpacked Size

    235 kB

    Total Files

    23

    Last publish

    Collaborators

    • azure-sdk