다음을 통해 공유


Sensors.RenewConnectionString Method

Definition

Renews a sensor connection string.

public virtual Azure.Response RenewConnectionString (string sensorPartnerId, string sensorId, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member RenewConnectionString : string * string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
override this.RenewConnectionString : string * string * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Response
Public Overridable Function RenewConnectionString (sensorPartnerId As String, sensorId As String, content As RequestContent, Optional context As RequestContext = Nothing) As Response

Parameters

sensorPartnerId
String

Id of the sensor partner.

sensorId
String

Id of the sensor resource.

content
RequestContent

The content to send as the body of the request. Details of the request body schema are in the Remarks section below.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The response returned from the service. Details of the response body schema are in the Remarks section below.

Exceptions

sensorPartnerId, sensorId or content is null.

sensorPartnerId or sensorId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

This sample shows how to call RenewConnectionString with required parameters and request content and parse the result.

var credential = new DefaultAzureCredential();
var client = new FarmBeatsClient(credential).GetSensorsClient(<2022-11-01-preview>);

var data = new {
    connectionStringType = "Primary",
};

Response response = client.RenewConnectionString("<sensorPartnerId>", "<sensorId>", RequestContent.Create(data));

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("primaryDeviceConnectionString").ToString());
Console.WriteLine(result.GetProperty("secondaryDeviceConnectionString").ToString());

Remarks

Below is the JSON schema for the request and response payloads.

Request Body:

Schema for SensorRenewConnectionStringModel:

{
  connectionStringType: "Primary" | "Secondary" | "Both", # Required. Specifies the type of connection string key to be renewed valid values - Primary/Secondary/Both.
}

Response Body:

Schema for IoTHubDeviceAuthentication:

{
  primaryDeviceConnectionString: string, # Optional. Primary connection string of the ioTHub device.
  secondaryDeviceConnectionString: string, # Optional. Secondary connection string of the ioTHub device.
}

Applies to