Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
YunchuWang committed Jan 9, 2025
1 parent 6a66aaa commit 131c575
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
24 changes: 13 additions & 11 deletions src/Extensions/Azure/DurableTaskSchedulerExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation.
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Azure.Core;
Expand Down Expand Up @@ -141,18 +141,20 @@ options.Credential is not null
ChannelCredentials.SecureSsl :
ChannelCredentials.Insecure;
return GrpcChannel.ForAddress(endpoint, new GrpcChannelOptions

Check failure on line 143 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

A new expression requires an argument list or (),

Check failure on line 143 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

) expected

Check failure on line 143 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

; expected

Check failure on line 143 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

A new expression requires an argument list or (),

Check failure on line 143 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

) expected

Check failure on line 143 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

; expected

Check failure on line 143 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs

View workflow job for this annotation

GitHub Actions / build

A new expression requires an argument list or (),

Check failure on line 143 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs

View workflow job for this annotation

GitHub Actions / build

) expected

Check failure on line 143 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs

View workflow job for this annotation

GitHub Actions / build

; expected

Check failure on line 143 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs

View workflow job for this annotation

GitHub Actions / build

A new expression requires an argument list or (),

Check failure on line 143 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs

View workflow job for this annotation

GitHub Actions / build

) expected

Check failure on line 143 in src/Extensions/Azure/DurableTaskSchedulerExtensions.cs

View workflow job for this annotation

GitHub Actions / build

; expected
{
// The same credential is being used for all operations.
// https://learn.microsoft.com/aspnet/core/grpc/authn-and-authz#set-the-bearer-token-with-callcredentials
Credentials = ChannelCredentials.Create(channelCreds, managedBackendCreds),

// TODO: This is not appropriate for use in production settings. Setting this to true should
// only be done for local testing. We should hide this setting behind some kind of flag.
UnsafeUseInsecureChannelCallCredentials = true,
});
return GrpcChannel.ForAddress(endpoint, new GrpcChannelOptions
{
// The same credential is being used for all operations.
// https://learn.microsoft.com/aspnet/core/grpc/authn-and-authz#set-the-bearer-token-with-callcredentials
Credentials = ChannelCredentials.Create(channelCreds, managedBackendCreds),

// TODO: This is not appropriate for use in production settings. Setting this to true should
// only be done for local testing. We should hide this setting behind some kind of flag.
UnsafeUseInsecureChannelCallCredentials = true,
});
}

static Exception RequiredOptionMissing(string optionName)
static ArgumentException RequiredOptionMissing(string optionName)
{
return new ArgumentException(message: $"Required option '{optionName}' was not provided.");
}
Expand All @@ -179,4 +181,4 @@ public async Task<AccessToken> GetTokenAsync(CancellationToken cancellationToken
return this.token.Value;
}
}
}
}
9 changes: 5 additions & 4 deletions src/Extensions/Azure/DurableTaskSchedulerOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// Licensed under the MIT License.

using System.Globalization;
using Azure.Core;
Expand All @@ -15,6 +15,9 @@ public class DurableTaskSchedulerOptions
/// <summary>
/// Initializes a new instance of the <see cref="DurableTaskSchedulerOptions"/> class.
/// </summary>
/// <param name="endpointAddress">The endpoint address of the Durable Task Scheduler service.</param>
/// <param name="taskHubName">The name of the task hub to connect to.</param>
/// <param name="credential">The credential to use for authentication, or null for no authentication.</param>
internal DurableTaskSchedulerOptions(string endpointAddress, string taskHubName, TokenCredential? credential = null)
{
this.EndpointAddress = endpointAddress ?? throw new ArgumentNullException(nameof(endpointAddress));
Expand Down Expand Up @@ -74,7 +77,6 @@ public static DurableTaskSchedulerOptions FromConnectionString(
// "Endpoint=https://myaccount.westus3.durabletask.io/;Authentication=ManagedIdentity;ClientID=00000000-0000-0000-0000-000000000000;TaskHubName=th01"
// "Endpoint=https://myaccount.westus3.durabletask.io/;Authentication=DefaultAzure;TaskHubName=th01"
// "Endpoint=https://myaccount.westus3.durabletask.io/;Authentication=None;TaskHubName=th01" (undocumented and only intended for local testing)

string endpointAddress = connectionString.Endpoint;

if (!endpointAddress.Contains("://"))
Expand All @@ -84,7 +86,6 @@ public static DurableTaskSchedulerOptions FromConnectionString(
}

string authType = connectionString.Authentication;

TokenCredential? credential;

// Parse the supported auth types, in a case-insensitive way and without spaces
Expand Down Expand Up @@ -159,4 +160,4 @@ public static DurableTaskSchedulerOptions FromConnectionString(
DurableTaskSchedulerOptions options = new(endpointAddress, connectionString.TaskHubName, credential);
return options;
}
}
}

0 comments on commit 131c575

Please sign in to comment.