Create an IoT hub using the Azure IoT Tools for Visual Studio Code

This article shows you how to use the Azure IoT Tools for Visual Studio Code to create an Azure IoT hub.

Note

This article has been updated to use the Azure Az PowerShell module. The Az PowerShell module is the recommended PowerShell module for interacting with Azure. To get started with the Az PowerShell module, see Install Azure PowerShell. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.

To complete this article, you need the following:

Create an IoT hub and device in an IoT Project

The following steps show how you can create an IoT Hub and register a device to the hub within an IoT Project in Visual Studio Code.

Instead of provisioning an Azure IoT Hub and device from the Azure portal. You can do it in the VS Code without leaving the development environment. The steps in this section show how to do this.

  1. In the new opened project window, click F1 to open the command palette, type and select Azure IoT Device Workbench: Provision Azure Services.... Follow the step-by-step guide to finish provisioning your Azure IoT Hub and creating the IoT Hub device.

    Provision command

    Note

    If you have not signed in Azure. Follow the pop-up notification for signing in.

  2. Select the subscription you want to use.

    Select sub

  3. Then select and existing resource group or create a new resource group.

    Select resource group

  4. In the resource group you specified, follow the prompts to select an existing IoT Hub or create a new Azure IoT Hub.

    Select IoT Hub steps

    Select IoT Hub

    Selected IoT Hub

  5. In the output window, you will see the Azure IoT Hub provisioned.

    IoT Hub Provisioned

  6. Select or create a new IoT Hub Device in the Azure IoT Hub you provisioned.

    Select IoT Device steps

    Select IoT Device Provisioned

  7. Now you have Azure IoT Hub provisioned and device created in it. Also the device connection string will be saved in VS Code.

    Provision done

Create an IoT hub without an IoT Project

The following steps show how you can create an IoT Hub without an IoT Project in Visual Studio Code.

  1. In Visual Studio Code, open the Explorer view.

  2. At the bottom of the Explorer, expand the Azure IoT Hub section.

    Expand Azure IoT Hub Devices

  3. Click on the ... in the Azure IoT Hub section header. If you don't see the ellipsis, hover over the header.

  4. Choose Create IoT Hub.

  5. A pop-up will show in the bottom-right corner to let you sign in to Azure for the first time.

  6. Select Azure subscription.

  7. Select resource group.

  8. Select location.

  9. Select pricing tier.

  10. Enter a globally unique name for your IoT Hub.

  11. Wait a few minutes until the IoT Hub is created.

Next steps

Now you have deployed an IoT hub using the Azure IoT Tools for Visual Studio Code. To explore further, check out the following articles: