title: How do I access Google Cloud Datastore emulator using .Net Core?
body: <p>I have this simple console program in .Net Core v3.1:</p>
  <pre><code>static void Main(string[] args)
  {
      var db = new DatastoreDbBuilder 
      {
          ProjectId = &quot;simple-proj&quot;,
          EmulatorDetection = EmulatorDetection.EmulatorOnly
      }.Build();
  
      var keyFactory = db.CreateKeyFactory(&quot;Simple&quot;);
      using (var transaction = db.BeginTransaction())
      {
          transaction.Insert(new Entity { Key = keyFactory.CreateIncompleteKey(), [&quot;Message&quot;] = &quot;Hello&quot; });
          transaction.Commit();
      }
  }
  </code></pre>
  <p>I'm using the the <em>Google.Cloud.Datastore.V1 v3.0.0</em> library to access the Datastore from my C# code. I started the emulator and set the environment variables using <em>$(gcloud beta emulators datastore env-init)</em> as the documentation says. I get an OK message back from the emulator endpoint (http://localhost:8081) when I access it via the browser. Everything seems to be in order.</p>
  <p>This is the stack dump I get on my .Net console:</p>
  <pre><code>Unhandled exception. Grpc.Core.RpcException: Status(StatusCode=Unavailable, Detail=&quot;failed to connect to all addresses&quot;)
     at Grpc.Core.Internal.AsyncCall`2.UnaryCall(TRequest msg)
     at Grpc.Core.Calls.BlockingUnaryCall[TRequest,TResponse](CallInvocationDetails`2 call, TRequest req)
     at Grpc.Core.DefaultCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
     at Grpc.Core.Interceptors.InterceptingCallInvoker.&lt;BlockingUnaryCall&gt;b__3_0[TRequest,TResponse](TRequest req, ClientInterceptorContext`2 ctx)
     at Grpc.Core.ClientBase.ClientBaseConfiguration.ClientBaseConfigurationInterceptor.BlockingUnaryCall[TRequest,TResponse](TRequest request, ClientInterceptorContext`2 context, BlockingUnaryCallContinuation`2 continuation)
     at Grpc.Core.Interceptors.InterceptingCallInvoker.BlockingUnaryCall[TRequest,TResponse](Method`2 method, String host, CallOptions options, TRequest request)
     at Google.Cloud.Datastore.V1.Datastore.DatastoreClient.BeginTransaction(BeginTransactionRequest request, CallOptions options)
     at Google.Api.Gax.Grpc.ApiCall.GrpcCallAdapter`2.CallSync(TRequest request, CallSettings callSettings)
     at Google.Api.Gax.Grpc.ApiCallRetryExtensions.&lt;&gt;c__DisplayClass1_0`2.&lt;WithRetry&gt;b__0(TRequest request, CallSettings callSettings)
     at Google.Api.Gax.Grpc.ApiCall`2.&lt;&gt;c__DisplayClass10_0.&lt;WithCallSettingsOverlay&gt;b__1(TRequest req, CallSettings cs)
     at Google.Api.Gax.Grpc.ApiCall`2.Sync(TRequest request, CallSettings perCallCallSettings)
     at Google.Cloud.Datastore.V1.DatastoreClientImpl.BeginTransaction(BeginTransactionRequest request, CallSettings callSettings)
     at Google.Cloud.Datastore.V1.DatastoreClient.BeginTransaction(String projectId, CallSettings callSettings)
     at Google.Cloud.Datastore.V1.DatastoreDbImpl.BeginTransaction(CallSettings callSettings)
     at simple.Simple.Main(String[] args) in /Users/wreid/git/leapsystems/research/console-reports/Simple.cs:line 20
  </code></pre>
  <p>And this is the corresponding Datastore emulator console message:</p>
  <pre><code>[datastore] Jul 24, 2020 5:48:42 PM io.gapi.emulators.grpc.GrpcServer$3 operationComplete
  [datastore] INFO: Adding handler(s) to newly registered Channel.
  [datastore] Jul 24, 2020 5:48:42 PM io.gapi.emulators.netty.HttpVersionRoutingHandler channelRead
  [datastore] INFO: Detected non-HTTP/2 connection.
  [datastore] Jul 24, 2020 5:48:42 PM io.gapi.emulators.netty.NotFoundHandler handleRequest
  [datastore] INFO: Unknown request URI: /bad-request
  </code></pre>
  <p>Am I missing something obvious somewhere either in my code or the setup of the emulator?</p>