Certificates - Create Or Update

Upload the certificate to the IoT hub.
Adds new or replaces existing certificate.

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}?api-version=2023-06-30

URI Parameters

Name In Required Type Description
certificateName
path True

string

The name of the certificate

Regex pattern: ^[A-Za-z0-9-._]{1,64}$

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.

subscriptionId
path True

string

The subscription identifier.

api-version
query True

string

The version of the API.

Request Header

Name Required Type Description
If-Match

string

ETag of the Certificate. Do not specify for creating a brand new certificate. Required to update an existing certificate.

Request Body

Name Type Description
properties

CertificateProperties

The description of an X509 CA Certificate.

Responses

Name Type Description
200 OK

CertificateDescription

If certificate already exist and update was successful, the operation returns HTTP status code of 201 (OK).

201 Created

CertificateDescription

If certificate didn't exist creation was successful, the operation returns HTTP status code of 201 (OK).

Other Status Codes

ErrorDetails

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

Certificates_CreateOrUpdate

Sample request

PUT https://management.azure.com/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/IotHubs/iothub/certificates/cert?api-version=2023-06-30

{
  "properties": {
    "certificate": "############################################"
  }
}

Sample response

{
  "properties": {
    "subject": "CN=testdevice1",
    "expiry": "Sat, 31 Dec 2039 23:59:59 GMT",
    "thumbprint": "97388663832D0393C9246CAB4FBA2C8677185A25",
    "isVerified": false,
    "created": "Thu, 12 Oct 2017 19:23:50 GMT",
    "updated": "Thu, 12 Oct 2017 19:23:50 GMT",
    "certificate": "############################################"
  },
  "id": "/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServives/myFirstProvisioningService/certificates/cert",
  "name": "cert",
  "type": "Microsoft.Devices/IotHubs/Certificates",
  "etag": "AAAAAAExpNs="
}
{
  "properties": {
    "subject": "CN=testdevice1",
    "expiry": "Sat, 31 Dec 2039 23:59:59 GMT",
    "thumbprint": "97388663832D0393C9246CAB4FBA2C8677185A25",
    "isVerified": false,
    "created": "Thu, 12 Oct 2017 19:23:50 GMT",
    "updated": "Thu, 12 Oct 2017 19:23:50 GMT",
    "certificate": "############################################"
  },
  "id": "/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServives/myFirstProvisioningService/certificates/cert",
  "name": "cert",
  "type": "Microsoft.Devices/IotHubs/Certificates",
  "etag": "AAAAAAExpNs="
}

Definitions

Name Description
CertificateDescription

The X509 Certificate.

CertificateProperties

The description of an X509 CA Certificate.

ErrorDetails

Error details.

CertificateDescription

The X509 Certificate.

Name Type Description
etag

string

The entity tag.

id

string

The resource identifier.

name

string

The name of the certificate.

properties

CertificateProperties

The description of an X509 CA Certificate.

type

string

The resource type.

CertificateProperties

The description of an X509 CA Certificate.

Name Type Description
certificate

string

The certificate content

created

string

The certificate's create date and time.

expiry

string

The certificate's expiration date and time.

isVerified

boolean

Determines whether certificate has been verified.

subject

string

The certificate's subject name.

thumbprint

string

The certificate's thumbprint.

updated

string

The certificate's last update date and time.

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.