2

Xamarin.AndroidでMicrosoft Azure Storage Emulatorを使用するには? Microsoft Azure Storage EmulatorとMicrosoft Azure Storage Explorerをダウンロードしました。私はMicrosoftのWebサイトでチュートリアルに従おうとしましたが、依然として認証に問題があります。私が無料トライアルのサブスクリプション中に本物を使用していたとき、XamarinでMicrosoft Azure Storage Emulatorを使用するには?

私はSASキーを使用する必要があることを知っています。しかし、私はストレージエクスプローラでテーブルストレージを作成し、そこにまだそれが間違っているSASを生成します。すでに誰かがそれを行い、ストレージエミュレータとの接続を再現するためのコードや手順を貼り付けることができます。

const string connectionString = "SharedAccessSignature=sv=2015-04-05&sr=c&sig=91HcGtCMxWM6%2B13mRDH1kej5Wq1a8gRk4WCFd6CeLuk%3D&se=2016-08-01T12%3A16%3A55Z&sp=rwdl;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1"; 

CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); 
CloudTableClient tableClient = storageAccount.CreateCloudTableClient(); 
CloudTable table = tableClient.GetTableReference("Test"); 
bool exists = await table.ExistsAsync(); 
if (exists) 
    System.Console.WriteLine("Exists"); 
else 
    System.Console.WriteLine("Doesnt exist"); 

エラーの詳細:

<RequestResult> 
    <HTTPStatusCode>0</HTTPStatusCode> 
    <HttpStatusMessage /> 
    <TargetLocation>Primary</TargetLocation> 
    <ServiceRequestID /> 
    <ContentMd5 /> 
    <Etag /> 
    <RequestDate /> 
    <StartTime>Sun, 31 Jul 2016 13:43:44 GMT</StartTime> 
    <EndTime>Sun, 31 Jul 2016 13:43:44 GMT</EndTime> 
    <Error></Error> 
    <ExceptionInfo> 
    <Type /> 
    <HResult>-2146233088</HResult> 
    <Message>Error: ConnectFailure (Connection refused)</Message> 
    <Source /> 
    <StackTrace /> 
    <InnerExceptionInfo> 
     <ExceptionInfo> 
     <Type /> 
     <HResult>-2146233079</HResult> 
     <Message>Error: ConnectFailure (Connection refused)</Message> 
     <Source>mscorlib</Source> 
     <StackTrace> at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x0005e] in /Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System/System.Net/HttpWebRequest.cs:1005 
    at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncCoreLogic (IAsyncResult iar, System.Func`2 endFunction, System.Action`1 endAction, System.Threading.Tasks.Task`1 promise, Boolean requiresSynchronization) [0x00014] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/threading/Tasks/FutureFactory.cs:550 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [0x0000c] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
    at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult() [0x00000] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 
    at System.Net.Http.HttpClientHandler+&lt;SendAsync&gt;c__async0.MoveNext() [0x003d6] in /Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClientHandler.cs:372 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [0x0000c] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
    at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult() [0x00000] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 
    at System.Net.Http.HttpClient+&lt;SendAsyncWorker&gt;c__async0.MoveNext() [0x000a9] in /Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System.Net.Http/System.Net.Http/HttpClient.cs:276 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [0x0000c] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
    at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
    at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult() [0x00000] in /Users/builder/data/lanes/2923/52635947/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:357 
    at Microsoft.WindowsAzure.Storage.Core.Executor.Executor+&lt;ExecuteAsyncInternal&gt;d__6`1[T].MoveNext() [0x003cf] in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\WindowsRuntime\Core\Executor\Executor.cs:128 </StackTrace> 
     <InnerExceptionInfo> 
      <ExceptionInfo> 
      <Type /> 
      <HResult>-2147467259</HResult> 
      <Message>Connection refused</Message> 
      <Source>System</Source> 
      <StackTrace> at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x000cb] in /Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System/System.Net.Sockets/Socket.cs:1313 
    at System.Net.WebConnection.Connect (System.Net.HttpWebRequest request) [0x0019b] in /Users/builder/data/lanes/2923/52635947/source/mono/mcs/class/System/System.Net/WebConnection.cs:195 </StackTrace> 
      </ExceptionInfo> 
     </InnerExceptionInfo> 
     </ExceptionInfo> 
    </InnerExceptionInfo> 
    </ExceptionInfo> 
</RequestResult> 

はお時間をいただき、ありがとうございます。

+0

「ストレージエクスプローラでテーブルストレージを作成してから、そこにSASを作成すると、まだ間違っています」ということを教えてください。 SASの何が問題なのですか? –

+0

そのSASを使用してストレージに接続しようとすると、接続エラーの例外が発生します。 – wasilewitz

+0

が表示されます。 SASトークンと、そのSASトークンを使用してストレージに接続するコードを共有できますか? –

答えて

0

このエラーが発生するのは、このコードをエミュレータで実行しているからです。あなたのエミュレータのIPアドレスは127.0.0.1なので、リクエストは実際にはストレージエミュレータには届かず、デバイスエミュレータにしか当てられません。そのため、この接続が拒否されたというエラーが発生しています。詳細については、このスレッドをご覧ください:https://forums.xamarin.com/discussion/1199/how-to-make-our-remote-host-127-0-0-1-reachable-from-android-device-monoandroid-using-vs2010

ストレージエミュレータではなく実際のクラウドストレージアカウントを使用してコードをテストすることをお勧めします。実際のストレージアカウントを使用する場合は、以下のコードを使用してください(明らかに接続文字列を適切に変更してください)。

 var connectionString = "http://127.0.0.1/devstoreaccount1/Testowa?st=2015-07-31T11%3A50%3A00Z&se=2017-0‌​8-01T11%3A50%3A00Z&sp=raud&sv=2015-04-05&tn=testowa&sig=UEbinBTgpEGwy1ts0hwmSfELM‌​1lYCBItLHgWpWSgvE4%3D"; 
     CloudTable table = new CloudTable(new Uri(connectionString)); 
     bool exists = await table.ExistsAsync(); 
     if (exists) 
      System.Console.WriteLine("Exists"); 
     else 
      System.Console.WriteLine("Doesnt exist"); 
+0

エミュレータではなく、デバイス上でコードを実行しています。しかし、少なくとも私は今SASが問題ではないが、ストレージエミュレータに接続することを知っている。あなたの時間をありがとう:)あなたは本当に私を助けた – wasilewitz

+0

あなたのデバイスは、あなたの携帯電話やコンピュータを意味しますか? –

+0

私の電話。 USB経由で接続 – wasilewitz

関連する問題