2017-06-03 20 views
1

hereと同じ問題。私はsimple sample to export the IOTのデバイスリストをblobストレージに追いかけるが、ExportDevicesAsyncの内部サーバーエラーが発生する。 北ヨーロッパを使用していますが、サーバーの変更は実際には有効な修正ではないと思います。Azure IOT ExportDevicesAsync内部サーバーエラー

私は戻って取得していますすべて:

An exception of type 'Microsoft.Azure.Devices.Common.Exceptions.ServerErrorException' occurred in mscorlib.dll but was not handled in user code 

Additional information: {"Message":"ErrorCode:ServerError;InternalServerError","ExceptionMessage":"Tracking ID:c51dad0227604f21b9af3e8acbd77f4c-G:5-TimeStamp:06/03/2017 19:56:10"} 

サンプルコード(マスクされた接続文字列とキー)

internal async Task GetAllDevices() 
{ 

    var ConnectionString = 
     "HostName=xxxx.azure-devices.net;SharedAccessKeyName=xxxxowner;SharedAccessKey=xxxxLr3xxxxXKKILLxxxxx"; 
    registryManager = RegistryManager.CreateFromConnectionString(ConnectionString); 

    var key = "https://xxxxotblob1.blob.core.windows.newt/?sv=2016-05-31&ss=bfqt&srt=sco&sp=rwdlxxxxup&se=2017-06-04T04:42:14Z&st=2017-06-03T20:42:14Z&spr=https&sig=kxxxxxxxxxxxxxxx%3D"; 

    JobProperties exportJob = await registryManager.ExportDevicesAsync(key,"device.txt", false); 

    while (true) 
    { 
     exportJob = await registryManager.GetJobAsync(exportJob.JobId); 
     if (exportJob.Status == JobStatus.Completed || 
      exportJob.Status == JobStatus.Failed || 
      exportJob.Status == JobStatus.Cancelled) 
     { 
      break; 
     } 

     await Task.Delay(TimeSpan.FromSeconds(5)); 
    } 

} 

は、私はここで何か間違ったことをやっていますか?私が見逃している実際の例外をキャッチする方法はありますか?

+0

この例外を引き起こす行はどれですか? –

+0

@ RitaHan-MSFTそれはオンラインです:JobProperties exportJob = await registryManager.ExportDevicesAsync(key、 "device.txt"、false); – Damo

答えて

1

exportBlobContainerUriの形式が間違っている可能性があります。右は次のようになります。

https://[StorageAccountName].blob.core.windows.net/[ContainerName]?sv=2016-05-31&sr=c&sig=mxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxw%3D&se=2017-06-06T02%3A07%3A22Z&sp=rwd 

あなたは、コンテナSAS URIを取得する手順は次のとおりです:

//1# Get your container: 

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
    CloudConfigurationManager.GetSetting("StorageConnectionString")); 

CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); 

CloudBlobContainer container = blobClient.GetContainerReference("mycontainer"); 

//2# Format the Uri: 

static string GetContainerSasUri(CloudBlobContainer container) 
{ 
    var sasConstraints = new SharedAccessBlobPolicy(); 
    sasConstraints.SharedAccessExpiryTime = DateTime.UtcNow.AddHours(24); 
    sasConstraints.Permissions = 
    SharedAccessBlobPermissions.Write | 
    SharedAccessBlobPermissions.Read | 
    SharedAccessBlobPermissions.Delete; 

    string sasContainerToken = container.GetSharedAccessSignature(sasConstraints); 

    return container.Uri + sasContainerToken; 
} 

詳細については、あなたはCreate a containerGet the container SAS URIを参照することができます。