Sensors.GetConnectionString(String, String, RequestContext) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets a sensor connection string.
public virtual Azure.Response GetConnectionString (string sensorPartnerId, string sensorId, Azure.RequestContext context = default);
abstract member GetConnectionString : string * string * Azure.RequestContext -> Azure.Response
override this.GetConnectionString : string * string * Azure.RequestContext -> Azure.Response
Public Overridable Function GetConnectionString (sensorPartnerId As String, sensorId As String, Optional context As RequestContext = Nothing) As Response
Parameters
- sensorPartnerId
- String
Id of the sensor partner.
- sensorId
- String
Id of the sensor resource.
- 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
or sensorId
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 GetConnectionString with required parameters and parse the result.
var credential = new DefaultAzureCredential();
var client = new FarmBeatsClient(credential).GetSensorsClient(<2022-11-01-preview>);
Response response = client.GetConnectionString("<sensorPartnerId>", "<sensorId>");
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 response payload.
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
Azure SDK for .NET