Sensors.GetConnectionStringAsync(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 System.Threading.Tasks.Task<Azure.Response> GetConnectionStringAsync (string sensorPartnerId, string sensorId, Azure.RequestContext context = default);
abstract member GetConnectionStringAsync : string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetConnectionStringAsync : string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetConnectionStringAsync (sensorPartnerId As String, sensorId As String, Optional context As RequestContext = Nothing) As Task(Of 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 GetConnectionStringAsync with required parameters and parse the result.
var credential = new DefaultAzureCredential();
var client = new FarmBeatsClient(credential).GetSensorsClient(<2022-11-01-preview>);
Response response = await client.GetConnectionStringAsync("<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