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. You can create one without an existing IoT project or create one from an existing IoT project.
We recommend that you use the Azure Az PowerShell module to interact with Azure. See Install Azure PowerShell to get started. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.
Azure IoT Tools installed for Visual Studio Code
An Azure resource group: create a resource group in the Azure portal
Create an IoT hub without an IoT Project
The following steps show how to create an IoT Hub without an IoT Project in Visual Studio Code (VS Code).
In VS Code, open the Explorer view.
At the bottom of the Explorer, expand the Azure IoT Hub section.
Select Create IoT Hub from the list in the Azure IoT Hub section.
A pop-up will show in the bottom-right corner to let you sign in to Azure for the first time, if you're not signed in already.
From the command palette at the top of VS Code, select your Azure subscription.
Select your resource group.
Select a location.
Select a pricing tier.
Enter a globally unique name for your IoT hub, then press Enter.
Wait a few minutes until the IoT hub is created. You'll see a confirmation in the output console.
Create an IoT hub and device in an existing IoT project
The following steps show how to create an IoT Hub and register a device to the hub within an existing IoT project in Visual Studio (VS) Code.
This method allows you to provision in VS Code without leaving your development environment.
In the new opened project window, click
F1to open the command palette, type and select Azure IoT Device Workbench: Provision Azure Services....
If you have not signed in Azure. Follow the pop-up notification for signing in.
Select the subscription you want to use.
Select an existing resource group or create a new resource group.
In the resource group you specified, follow the prompts to select an existing IoT Hub or create a new Azure IoT Hub.
In the output window, you'll see the Azure IoT Hub provisioned.
Select or create a new IoT Hub Device in the Azure IoT Hub you provisioned.
Now you have an Azure IoT Hub provisioned and a device created in it. The device connection string will be saved in VS Code.
To delete a device from your IoT hub, use the
Azure IoT Hub: Delete Device option from the Command Palette. There is no option to delete your IoT hub in Visual Studio Code, however you can delete your hub in the Azure portal.
Now that you've deployed an IoT hub using the Azure IoT Tools for Visual Studio Code, explore these articles: