Azure Device Registry Software Update client library for Python - version 1.0.0b1

Azure Device Registry Software Update enables you to import and manage software updates and inspect device classes for IoT devices registered with Azure Device Registry.

Getting started

Install the package

python -m pip install azure-iot-deviceregistrysoftwareupdate

Prerequisites

  • Python 3.10 or later is required to use this package.
  • You need an Azure subscription to use this package.
  • An existing Azure Device Registry Software Update instance and its endpoint hostname, such as contoso.api.adu.microsoft.com.

Use with AI tools

AI coding tools such as VS Code and GitHub Copilot can help you write and debug code that uses this library. See Using the Azure SDK for Python with AI tools for available integrations.

Create with an Azure Active Directory Credential

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 pip install azure-identity

After setup, 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:

>>> from azure.iot.deviceregistrysoftwareupdate import DeviceRegistrySoftwareUpdateClient
>>> from azure.identity import DefaultAzureCredential
>>> client = DeviceRegistrySoftwareUpdateClient(endpoint='<endpoint>', credential=DefaultAzureCredential())

Key concepts

The DeviceRegistrySoftwareUpdateClient provides access to two operation groups:

  • device_classes manages device classes.
  • software_update manages software updates and update files.

Examples

import os

from azure.core.exceptions import HttpResponseError
from azure.identity import DefaultAzureCredential
from azure.iot.deviceregistrysoftwareupdate import DeviceRegistrySoftwareUpdateClient

endpoint = os.environ["DEVICE_REGISTRY_SOFTWARE_UPDATE_ENDPOINT"]

try:
    with DeviceRegistrySoftwareUpdateClient(
        endpoint=endpoint,
        credential=DefaultAzureCredential(),
    ) as client:
        for device_class in client.device_classes.list():
            print(device_class)
except HttpResponseError as error:
    print(f"Service request failed: {error}")

Troubleshooting

Service operations raise exceptions defined in Azure Core.

Next steps

Explore the available client operations and models in the API reference.

Contributing

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 repos 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.