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.
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:
An Azure subscription. If you don't have an Azure subscription, create a free account before you begin.
Azure IoT Tools installed for Visual Studio Code.
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.
In the new opened project window, click
F1to 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.
If you have not signed in Azure. Follow the pop-up notification for signing in.
Select the subscription you want to use.
Then select and 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 will see the Azure IoT Hub provisioned.
Select or create a new IoT Hub Device in the Azure IoT Hub you provisioned.
Now you have Azure IoT Hub provisioned and device created in it. Also the device connection string will be saved in VS Code.
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.
In Visual Studio Code, open the Explorer view.
At the bottom of the Explorer, expand the Azure IoT Hub section.
Click on the ... in the Azure IoT Hub section header. If you don't see the ellipsis, hover over the header.
Choose Create IoT Hub.
A pop-up will show in the bottom-right corner to let you sign in to Azure for the first time.
Select Azure subscription.
Select resource group.
Select pricing tier.
Enter a globally unique name for your IoT Hub.
Wait a few minutes until the IoT Hub is created.
Now you have deployed an IoT hub using the Azure IoT Tools for Visual Studio Code. To explore further, check out the following articles: