[] IoT: Azure CLI Azure IoT Hub |
~/.bashrc
, , , MacOS. az Azure CLI, ~/.bash_profile
. bash nano ~/.bash_profile
, :export PATH=\~/bin:$PATH
cd ~/
touch .bash_profile
az --version
acs (2.0.0)
appservice (0.1.1b5)
batch (0.1.1b4)
cloud (2.0.0)
component (2.0.0)
configure (2.0.0)
container (0.1.1b4)
core (2.0.0)
documentdb (0.1.1b2)
feedback (2.0.0)
keyvault (0.1.1b5)
network (2.0.0)
nspkg (2.0.0)
profile (2.0.0)
redis (0.1.1b3)
resource (2.0.0)
role (2.0.0)
sql (0.1.1b5)
storage (2.0.1)
vm (2.0.0)
Python (Darwin) 2.7.10 (default, Jul 30 2016, 19:40:32)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)]
az login
az account set --subscription
az component update --add iot
az provider register -namespace Microsoft.Devices
az version
.acs (2.0.0)
appservice (0.1.1b5)
......
iot (0.1.1b3)
......
device
hub
:az iot device -h
az iot hub -h
.az group create --name yourresourcegroupname --location westus
az iot hub create --name youriothubname --location yourlocation --sku S1 --unit 1 --resource-group yourresourcegroupname
SKU S1
, IoT Hub F1 ( : {F1,S1,S2,S3}
). , unit
, IoT Hub. , IoT Hub. IoT Hub . ( ): {westus,northeurope,eastasia,eastus,westeurope,southeastasia,japaneast,japanwest,australiaeast,australiasoutheast,westus2,westcentralus}
.{
"etag": "AAAAAAC2NAc=",
"id": "/subscriptions/yournamespace/providers/Microsoft.Devices/IotHubs/youriothubname",
"location": "westus",
"name": "youriothubname",
"properties": {
....
}
},
...
'' "type": "Microsoft.Devices/IotHubs"
}
az iot hub list -g yourresourcegroupname
IoT Hub, . , IoT Hub . IoT Hub : az iot hub show -g yourresourcegroupname --name yourhubname
.az iot hub policy list --hub-name youriothubname
. IoT Hub. , . , iothubowner
IoT Hub , , .az iot hub show-connection-string -g yourresourcegroupname
.iothubowner
, IoT Hub. . . --policy-name
.az iot device
device; IoT Hub Explorer. IoT Hub Explorer . , IoT Hub Explorer IoT- Azure CLI.-debug
, , . , :az iot hub show-connection-string -g yourresourcegroupname --debug"
Command arguments ['iot', 'hub', 'show-connection-string', '-g', 'yourrgname']
Current active cloud 'AzureCloud'
{'active_directory': 'https://login.microsoftonline.com',
'active_directory_graph_resource_id': 'https://graph.windows.net/',
'active_directory_resource_id': 'https://management.core.windows.net/',
'management': 'https://management.core.windows.net/',
.......
'storage_endpoint': 'core.windows.net'}
Registered application event handler 'CommandTableParams.Loaded' at
Registered application event handler 'CommandTable.Loaded' at
Successfully loaded command table from module 'iot'.
..........
g': 'gzip, deflate'
msrest.http_logger : 'Accept': 'application/json'
msrest.http_logger : 'User-Agent': 'python/2.7.10 (Darwin-16.4.0-x86_64-i386-64bit) requests/2.13.0 msrest/0.4.6 msrest_azure/0.4.7 iothubclient/0.2.1 Azure-SDK-For-Python AZURECLI/2.0.0'
msrest.http_logger : 'Authorization': 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6ImEzUU4wQlpTN3M0bk4tQmRyamJGMFlfTGRNTSIsImtpZCI6ImEzUU4wQlpTN3M0bk4tQmRyamJGMFlfTGRNTSJ9.eyJhdWQiOiJodHRwczovL21hbmFnZW1lbnQuY29yZS53aW5kb3dzLm5ldC8iLCJpc3MiOiJodHRwcz0cy53aW5kb3dzLm5ldC83MmY5ODhiZi04NmYxLTQxYWYtOTFhYi0yZDdjZDAxMWRiNDcvIiwiaWF0IjoxNDg5NjEzODc5LCJuYmYiOjE0ODk2MTM4NzksImV4cCI6MTQ4OTYxNzc3OSwiX2NsYWltX25hbWVzIjp7Imdyb3VwcyI6InNyYzEifSwiX2NsYWltX3NvdXJjZXMiOnsic3JjMSI6eyJlbmRwb2ludCI6Imh0dHBzOi8vZ3JhcGgud2luZG93cy5uZXQvNzJmOTg4YmYtODZmMS00MWFmLTkxYWItMmQ3Y2QwMTFkYjQ3L3VzZXJzL2UyZTNkNDdlLTRiYzAtNDg1Yy04OTE1LWYyMDVkYzRlODY5YS9n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Futn7iD8E-etkVI9btE1aseZ3vvZqYeKPhA1VytBsTpb4XO2ZI094VynTeALoxe7bbuEzl5YaeqtbC5EM0PMhPB04o7K1ZF49nGKvA385MHJU3G-_JT3zV-wdQWDj5QKfkEJ0a9AsQ9fM7bxyTdm_m5tQ4a-kp61r92e1SzcpXgCD7TXRHxrZ2wa65rtD8tRmHt6LOi7a4Yx2wPFUpFoeQAcN7p7RKW6t_Cn8eyyvWrrUXximBcTB4rtQTgXCfVUw'
--debug
:[
{
"connectionString": "HostName=youriothub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=yourkey=,
"name": "youriothub"
}
]
output
. , . , , , JSON ( ) .az iot hub show-connection-string -g yourresourcegroupname -o table"
ConnectionString -------------------------------------------------------------------------------------------------------------------------------------- --------------
HostName=youriothub.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=yourkey=
Name
youriothub
az iot hub list --query "[?contains(location,'westus')].{Name:name}" -o tsv