Azure Resource Manager 템플릿을 사용하여 IoT Hub 만들기(PowerShell)

이 문서에서는 Azure Resource Manager 템플릿을 사용하여 Azure PowerShell을 사용하여 IoT Hub 및 소비자 그룹을 만드는 방법을 보여 줍니다. Resource Manager 템플릿은 솔루션에 배포해야 하는 리소스를 정의하는 JSON 파일입니다. Resource Manager 템플릿을 개발하는 방법에 대한 자세한 내용은 Azure Resource Manager 설명서를 참조하세요.

필수 조건

Azure PowerShell 모듈 또는 Azure Cloud Shell

Azure Cloud Shell은 Cloud Shell이 브라우저에서 수행하는 것처럼 PowerShell 모듈을 로컬로 설치하지 않으려는 경우에 유용합니다.

IoT Hub 만들기

이 문서에 사용된 Resource Manager JSON 템플릿Azure 빠른 시작 템플릿의 여러 템플릿 중 하나입니다. JSON 템플릿은 엔드포인트 3개(eventhub, cloud-to-device, messaging)와 소비자 그룹 1개를 사용하여 Azure Iot 허브를 만듭니다. IoT Hub 템플릿 스키마에 대한 자세한 내용은 Microsoft.Devices(IoT Hub) 리소스 종류를 참조하세요.

다음 PowerShell 명령을 사용하여 IoT 허브를 만드는 데 사용되는 리소스 그룹을 만듭니다. JSON 템플릿은 -TemplateUri에서 사용됩니다.

다음 PowerShell 스크립트를 실행하려면 시도를 선택하여 Azure Cloud Shell을 엽니다. 스크립트를 복사하여 셸에 붙여넣은 다음, Enter 키를 누릅니다. 프롬프트에 답변합니다. 이러한 프롬프트는 새 리소스를 만들고, 지역을 선택하고, 새 IoT 허브를 만드는 데 도움이 됩니다. 응답이 완료되면 IoT 허브 확인이 콘솔에 출력됩니다.

$resourceGroupName = Read-Host -Prompt "Enter the Resource Group name"
$location = Read-Host -Prompt "Enter the location (for example: centralus)"
$iotHubName = Read-Host -Prompt "Enter the IoT Hub name"

New-AzResourceGroup -Name $resourceGroupName -Location "$location"
New-AzResourceGroupDeployment `
    -ResourceGroupName $resourceGroupName `
    -TemplateUri "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.devices/iothub-with-consumergroup-create/azuredeploy.json" `
    -iotHubName $iotHubName

참고 항목

고유한 템플릿을 사용하려면 템플릿 파일을 Cloud Shell에 업로드한 다음 -TemplateFile 스위치를 사용하여 파일 이름을 지정합니다. 예를 들어 템플릿 배포를 참조하세요.

다음 단계

Azure Resource Manager 템플릿을 사용하여 IoT Hub를 배포했으므로 다음을 탐색할 수 있습니다.

IoT Hub를 개발하는 방법에 대한 자세한 내용은 Azure IoT SDK를 참조하세요.

IoT Hub의 추가 기능을 탐색하려면 다음을 참조하세요.