gpt4 book ai didi

azure - azure 配置服务出现格式错误的 token 异常

转载 作者:行者123 更新时间:2023-12-03 02:59:41 30 4
gpt4 key购买 nike

我按照https://learn.microsoft.com/en-us/azure/iot-dps/tutorial-net-provision-device-to-hub中的确切步骤进行操作注册设备。

我收到“格式错误的 token ”异常。

这是上面链接中的代码

private const string SampleRegistrationId = "sample-individual-csharp";
private const string SampleTpmEndorsementKey = "****"; //Key from Azure portal
private const string OptionalDeviceId = "myCSharpDevice";
private const ProvisioningStatus OptionalProvisioningStatus = ProvisioningStatus.Enabled;


static async Task SetRegistrationDataAsync()
{
Console.WriteLine("Starting SetRegistrationData");

Attestation attestation = new TpmAttestation(SampleTpmEndorsementKey);

IndividualEnrollment individualEnrollment = new IndividualEnrollment(SampleRegistrationId, attestation);

individualEnrollment.DeviceId = OptionalDeviceId;
individualEnrollment.ProvisioningStatus = OptionalProvisioningStatus;

Console.WriteLine("\nAdding new individualEnrollment...");
var serviceClient = ProvisioningServiceClient.CreateFromConnectionString(ServiceConnectionString);

IndividualEnrollment individualEnrollmentResult =
await serviceClient.CreateOrUpdateIndividualEnrollmentAsync(individualEnrollment).ConfigureAwait(false);

Console.WriteLine("\nIndividualEnrollment created with success.");
Console.WriteLine(individualEnrollmentResult);
}

最佳答案

我认为您使用的连接字符串格式不正确。请注意,不要包含“;”在连接字符串的末尾。也许从 Azure 门户复制连接字符串是避免使用不正确的连接字符串的好方法。 enter image description here如果错误仍然存​​在,请随时告诉我。

关于azure - azure 配置服务出现格式错误的 token 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50246549/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com