From 574dc0cb3dae726bb3cccdb231627ef71e8147ab Mon Sep 17 00:00:00 2001 From: MonkeyTennis Date: Tue, 18 Jul 2023 19:10:11 +0100 Subject: [PATCH 1/4] Rev'ed Grpc.Net.Client PackageReference version for Dapr dotnet-sdk (#1126) Rev'ed Grpc.Net.Client PackageReference version for Dapr dotnet-sdk Signed-off-by: Bradley Cotier --- examples/AspNetCore/GrpcServiceSample/GrpcServiceSample.csproj | 2 +- src/Dapr.Client/Dapr.Client.csproj | 2 +- test/Dapr.Client.Test/Dapr.Client.Test.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/AspNetCore/GrpcServiceSample/GrpcServiceSample.csproj b/examples/AspNetCore/GrpcServiceSample/GrpcServiceSample.csproj index 23ead7d4d..5ce78bc57 100644 --- a/examples/AspNetCore/GrpcServiceSample/GrpcServiceSample.csproj +++ b/examples/AspNetCore/GrpcServiceSample/GrpcServiceSample.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/Dapr.Client/Dapr.Client.csproj b/src/Dapr.Client/Dapr.Client.csproj index 7c9ff8160..59a38a3e4 100644 --- a/src/Dapr.Client/Dapr.Client.csproj +++ b/src/Dapr.Client/Dapr.Client.csproj @@ -21,7 +21,7 @@ - + diff --git a/test/Dapr.Client.Test/Dapr.Client.Test.csproj b/test/Dapr.Client.Test/Dapr.Client.Test.csproj index c94f031e9..36f9e725b 100644 --- a/test/Dapr.Client.Test/Dapr.Client.Test.csproj +++ b/test/Dapr.Client.Test/Dapr.Client.Test.csproj @@ -11,7 +11,7 @@ - + From f788efabdee06f4ff139e0a390d347b454608e6e Mon Sep 17 00:00:00 2001 From: Artur Souza Date: Tue, 18 Jul 2023 11:25:17 -0700 Subject: [PATCH 2/4] Add support to DAPR_HTTP_ENDPOINT and DAPR_GRPC_ENDPOINT env. (#1124) Signed-off-by: Artur Souza --- .../dotnet-client/dotnet-daprclient-usage.md | 6 ++++-- .../Runtime/ActorRuntimeOptions.cs | 5 +++-- src/Dapr.Client/DaprClientBuilder.cs | 5 +++-- .../WorkflowServiceCollectionExtensions.cs | 6 ++++++ src/Shared/DaprDefaults.cs | 20 +++++++++++++++---- 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/daprdocs/content/en/dotnet-sdk-docs/dotnet-client/dotnet-daprclient-usage.md b/daprdocs/content/en/dotnet-sdk-docs/dotnet-client/dotnet-daprclient-usage.md index 00b330693..26328050c 100644 --- a/daprdocs/content/en/dotnet-sdk-docs/dotnet-client/dotnet-daprclient-usage.md +++ b/daprdocs/content/en/dotnet-sdk-docs/dotnet-client/dotnet-daprclient-usage.md @@ -34,8 +34,10 @@ The `DaprClientBuilder` contains settings for: The SDK will read the following environment variables to configure the default values: -- `DAPR_HTTP_PORT`: used to find the HTTP endpoint of the Dapr sidecar -- `DAPR_GRPC_PORT`: used to find the gRPC endpoint of the Dapr sidecar +- `DAPR_HTTP_ENDPOINT`: used to find the HTTP endpoint of the Dapr sidecar, example: `https://dapr-api.mycompany.com` +- `DAPR_GRPC_ENDPOINT`: used to find the gRPC endpoint of the Dapr sidecar, example: `https://dapr-grpc-api.mycompany.com` +- `DAPR_HTTP_PORT`: if `DAPR_HTTP_ENDPOINT` is not set, this is used to find the HTTP local endpoint of the Dapr sidecar +- `DAPR_GRPC_PORT`: if `DAPR_GRPC_ENDPOINT` is not set, this is used to find the gRPC local endpoint of the Dapr sidecar - `DAPR_API_TOKEN`: used to set the API Token ### Configuring gRPC channel options diff --git a/src/Dapr.Actors/Runtime/ActorRuntimeOptions.cs b/src/Dapr.Actors/Runtime/ActorRuntimeOptions.cs index 3f4a6df88..30ee7b476 100644 --- a/src/Dapr.Actors/Runtime/ActorRuntimeOptions.cs +++ b/src/Dapr.Actors/Runtime/ActorRuntimeOptions.cs @@ -220,8 +220,9 @@ public int? RemindersStoragePartitions /// /// /// The URI endpoint to use for HTTP calls to the Dapr runtime. The default value will be - /// http://127.0.0.1:DAPR_HTTP_PORT where DAPR_HTTP_PORT represents the value of the - /// DAPR_HTTP_PORT environment variable. + /// DAPR_HTTP_ENDPOINT first, or http://127.0.0.1:DAPR_HTTP_PORT as fallback + /// where DAPR_HTTP_ENDPOINT and DAPR_HTTP_PORT represents the value of the + /// corresponding environment variables. /// /// public string HttpEndpoint { get; set; } = DaprDefaults.GetDefaultHttpEndpoint(); diff --git a/src/Dapr.Client/DaprClientBuilder.cs b/src/Dapr.Client/DaprClientBuilder.cs index 5b484e208..1580afb36 100644 --- a/src/Dapr.Client/DaprClientBuilder.cs +++ b/src/Dapr.Client/DaprClientBuilder.cs @@ -63,8 +63,9 @@ public DaprClientBuilder() /// /// /// The URI endpoint to use for HTTP calls to the Dapr runtime. The default value will be - /// http://127.0.0.1:DAPR_HTTP_PORT where DAPR_HTTP_PORT represents the value of the - /// DAPR_HTTP_PORT environment variable. + /// DAPR_HTTP_ENDPOINT first, or http://127.0.0.1:DAPR_HTTP_PORT as fallback + /// where DAPR_HTTP_ENDPOINT and DAPR_HTTP_PORT represents the value of the + /// corresponding environment variables. /// /// The instance. public DaprClientBuilder UseHttpEndpoint(string httpEndpoint) diff --git a/src/Dapr.Workflow/WorkflowServiceCollectionExtensions.cs b/src/Dapr.Workflow/WorkflowServiceCollectionExtensions.cs index 161c29175..c24265475 100644 --- a/src/Dapr.Workflow/WorkflowServiceCollectionExtensions.cs +++ b/src/Dapr.Workflow/WorkflowServiceCollectionExtensions.cs @@ -104,6 +104,12 @@ static bool TryGetGrpcAddress(out string address) // 1. DaprDefaults.cs uses 127.0.0.1 instead of localhost, which prevents testing with Dapr on WSL2 and the app on Windows // 2. DaprDefaults.cs doesn't compile when the project has C# nullable reference types enabled. // If the above issues are fixed (ensuring we don't regress anything) we should switch to using the logic in DaprDefaults.cs. + string? daprEndpoint = Environment.GetEnvironmentVariable("DAPR_GRPC_ENDPOINT"); + if (!String.IsNullOrEmpty(daprEndpoint)) { + address = daprEndpoint; + return true; + } + string? daprPortStr = Environment.GetEnvironmentVariable("DAPR_GRPC_PORT"); if (int.TryParse(daprPortStr, out int daprGrpcPort)) { diff --git a/src/Shared/DaprDefaults.cs b/src/Shared/DaprDefaults.cs index 28c02c148..1ddab49b0 100644 --- a/src/Shared/DaprDefaults.cs +++ b/src/Shared/DaprDefaults.cs @@ -57,13 +57,19 @@ public static string GetDefaultAppApiToken() } /// - /// Get the value of environment variable DAPR_HTTP_PORT + /// Get the value of HTTP endpoint based off environment variables /// - /// The value of environment variable DAPR_HTTP_PORT + /// The value of HTTP endpoint based off environment variables public static string GetDefaultHttpEndpoint() { if (httpEndpoint == null) { + var endpoint = Environment.GetEnvironmentVariable("DAPR_HTTP_ENDPOINT"); + if (!string.IsNullOrEmpty(endpoint)) { + httpEndpoint = endpoint; + return httpEndpoint; + } + var port = Environment.GetEnvironmentVariable("DAPR_HTTP_PORT"); port = string.IsNullOrEmpty(port) ? "3500" : port; httpEndpoint = $"http://127.0.0.1:{port}"; @@ -73,13 +79,19 @@ public static string GetDefaultHttpEndpoint() } /// - /// Get the value of environment variable DAPR_GRPC_PORT + /// Get the value of gRPC endpoint based off environment variables /// - /// The value of environment variable DAPR_GRPC_PORT + /// The value of gRPC endpoint based off environment variables public static string GetDefaultGrpcEndpoint() { if (grpcEndpoint == null) { + var endpoint = Environment.GetEnvironmentVariable("DAPR_GRPC_ENDPOINT"); + if (!string.IsNullOrEmpty(endpoint)) { + grpcEndpoint = endpoint; + return grpcEndpoint; + } + var port = Environment.GetEnvironmentVariable("DAPR_GRPC_PORT"); port = string.IsNullOrEmpty(port) ? "50001" : port; grpcEndpoint = $"http://127.0.0.1:{port}"; From 6dae4e339dff5965c936b1bb62b8ef793faad8c6 Mon Sep 17 00:00:00 2001 From: Aaron Crawfis Date: Tue, 18 Jul 2023 11:39:16 -0700 Subject: [PATCH 3/4] Add cascading metadata (#1128) Signed-off-by: Aaron Crawfis --- daprdocs/content/en/dotnet-sdk-docs/_index.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/daprdocs/content/en/dotnet-sdk-docs/_index.md b/daprdocs/content/en/dotnet-sdk-docs/_index.md index 65d818723..e823ca29f 100644 --- a/daprdocs/content/en/dotnet-sdk-docs/_index.md +++ b/daprdocs/content/en/dotnet-sdk-docs/_index.md @@ -5,6 +5,11 @@ linkTitle: ".NET" weight: 1000 description: .NET SDK packages for developing Dapr applications no_list: true +cascade: + github_repo: https://github.com/dapr/dotnet-sdk + github_subdir: daprdocs/content/en/dotnet-sdk-docs + path_base_for_github_subdir: content/en/developing-applications/sdks/dotnet/ + github_branch: master --- Dapr offers a variety of packages to help with the development of .NET applications. Using them you can create .NET clients, servers, and virtual actors with Dapr. From 2449bcd6691eb49825e0e8e9dff50bd50fd41c2e Mon Sep 17 00:00:00 2001 From: Hannah Hunter <94493363+hhunter-ms@users.noreply.github.com> Date: Tue, 18 Jul 2023 15:51:12 -0400 Subject: [PATCH 4/4] remove invalid code line (#1127) Signed-off-by: Hannah Hunter --- .../dotnet-sdk-docs/dotnet-actors/dotnet-actors-howto.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/daprdocs/content/en/dotnet-sdk-docs/dotnet-actors/dotnet-actors-howto.md b/daprdocs/content/en/dotnet-sdk-docs/dotnet-actors/dotnet-actors-howto.md index 986562ca8..5b79d6b8f 100644 --- a/daprdocs/content/en/dotnet-sdk-docs/dotnet-actors/dotnet-actors-howto.md +++ b/daprdocs/content/en/dotnet-sdk-docs/dotnet-actors/dotnet-actors-howto.md @@ -306,14 +306,6 @@ namespace MyActorService { app.UseDeveloperExceptionPage(); } - else - { - // By default, ASP.Net Core uses port 5000 for HTTP. The HTTP - // redirection will interfere with the Dapr runtime. You can - // move this out of the else block if you use port 5001 in this - // example, and developer tooling (such as the VSCode extension). - app.UseHttpsRedirection(); - } app.UseRouting();