Iot Hub Resource - List Keys

Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security
Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security.

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys?api-version=2018-04-01

URI Parameters

Name In Required Type Description
subscriptionId
path True
  • string

The subscription identifier.

resourceGroupName
path True
  • string

The name of the resource group that contains the IoT hub.

resourceName
path True
  • string

The name of the IoT hub.

api-version
query True
  • string

The version of the API.

Responses

Name Type Description
200 OK

This is a synchronous operation. The body contains a JSON-serialized array of shared access policies, including keys, that you can use to access the IoT hub endpoints.

Other Status Codes

DefaultErrorResponse

Security

azure_auth

Azure Active Directory OAuth2 Flow

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

IotHubResource_ListKeys

Sample Request

POST https://management.azure.com/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/IotHubs/testHub/listkeys?api-version=2018-04-01

Sample Response

{
  "value": [
    {
      "keyName": "iothubowner",
      "primaryKey": "2aWPrKloLLdcug12ZHNpA0e07yJmRRmYMXDLpEOTd/Y=",
      "secondaryKey": "DLyFnDTGMDK0BU2QjT5TCkNBQ4h08mi20vOqWMC7TxU=",
      "rights": "RegistryWrite, ServiceConnect, DeviceConnect"
    },
    {
      "keyName": "service",
      "primaryKey": "DinqxWW+s814W2Pc3dLxleelksqSYGy8Jfymt8J7a4c=",
      "secondaryKey": "5G8KgJ9Wx2T0f6HRIn25TgYcFmJnBSivawNaHssiP9Y=",
      "rights": "ServiceConnect"
    },
    {
      "keyName": "device",
      "primaryKey": "o/9gPc0oD8LY/r2lRurgl9U/sKFcL2c/tmFLKAiz+e0=",
      "secondaryKey": "YOeBMHnYP95vH+ykR8OeapnhS6W8raMsXOdNFwqg4lg=",
      "rights": "DeviceConnect"
    },
    {
      "keyName": "registryRead",
      "primaryKey": "h2d4mPxy6jPCWX6mO+katV9QPNJivzt4aFq0iGVc1A8=",
      "secondaryKey": "3TdcalZNTB7BZHl88LGsG1Z5T6+ElEODunrs1vylwGg=",
      "rights": "RegistryRead"
    },
    {
      "keyName": "registryReadWrite",
      "primaryKey": "tyNRcaI38fXL+gQTjCmrVZGTP4YFF7uACk7pppWLWzY=",
      "secondaryKey": "6P6DXOp0W3HO5/IotzcPS1kx7PHiOdesaND07Im5cYI=",
      "rights": "RegistryWrite"
    }
  ]
}

Definitions

AccessRights

The permissions assigned to the shared access policy.

ErrorDetails

Error details.

SharedAccessSignatureAuthorizationRule

The properties of an IoT hub shared access policy.

SharedAccessSignatureAuthorizationRuleListResult

The list of shared access policies with a next link.

AccessRights

The permissions assigned to the shared access policy.

Name Type Description
DeviceConnect
  • string
RegistryRead
  • string
RegistryRead, DeviceConnect
  • string
RegistryRead, RegistryWrite
  • string
RegistryRead, RegistryWrite, DeviceConnect
  • string
RegistryRead, RegistryWrite, ServiceConnect
  • string
RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect
  • string
RegistryRead, ServiceConnect
  • string
RegistryRead, ServiceConnect, DeviceConnect
  • string
RegistryWrite
  • string
RegistryWrite, DeviceConnect
  • string
RegistryWrite, ServiceConnect
  • string
RegistryWrite, ServiceConnect, DeviceConnect
  • string
ServiceConnect
  • string
ServiceConnect, DeviceConnect
  • string

ErrorDetails

Error details.

Name Type Description
code
  • string

The error code.

details
  • string

The error details.

httpStatusCode
  • string

The HTTP status code.

message
  • string

The error message.

SharedAccessSignatureAuthorizationRule

The properties of an IoT hub shared access policy.

Name Type Description
keyName
  • string

The name of the shared access policy.

primaryKey
  • string

The primary key.

rights

The permissions assigned to the shared access policy.

secondaryKey
  • string

The secondary key.

SharedAccessSignatureAuthorizationRuleListResult

The list of shared access policies with a next link.

Name Type Description
nextLink
  • string

The next link.

value

The list of shared access policies.