Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
51d210f
Add gradle task to update submodule and update proto to latest version
YunchuWang Jan 23, 2025
8660f1b
bump build pipeline github action version to non deprecated version
YunchuWang Jan 23, 2025
8a54ce4
initial dts support changes
YunchuWang Jan 23, 2025
f951428
placeholder
YunchuWang Jan 23, 2025
12e9e50
ignore
YunchuWang Jan 23, 2025
3b09d59
update
YunchuWang Jan 23, 2025
32eca1e
remove
YunchuWang Jan 23, 2025
ea2e181
update
YunchuWang Jan 23, 2025
e025538
update
YunchuWang Jan 23, 2025
6ea3a65
update
YunchuWang Jan 23, 2025
2270ed2
signing is disabled, should not exclude as there is no sign
YunchuWang Jan 23, 2025
9a02b23
save
YunchuWang Jan 29, 2025
8fb193f
feedback changes
YunchuWang Jan 29, 2025
a51ba86
delete legacy lib/java
YunchuWang Jan 29, 2025
7241e34
create skeleton project for pkg "com.microsoft.durabletask-azuremanaged"
YunchuWang Jan 29, 2025
8688320
split pkg in progress
YunchuWang Mar 14, 2025
628c093
move out
YunchuWang Mar 18, 2025
a7e8d19
progress
YunchuWang Mar 18, 2025
ab89785
p
YunchuWang Mar 18, 2025
6fc0748
progress
YunchuWang Mar 18, 2025
e3406d7
progress
YunchuWang Mar 18, 2025
110306e
fix
YunchuWang Mar 18, 2025
b7a88af
p
YunchuWang Mar 18, 2025
1b7fe1c
save
YunchuWang Mar 19, 2025
b74d699
save
YunchuWang Mar 19, 2025
f6611af
save
YunchuWang Mar 19, 2025
03df094
save
YunchuWang Mar 19, 2025
3cd3598
clientoptions done
YunchuWang Mar 19, 2025
357ecdd
client ext
YunchuWang Mar 19, 2025
df4a0e4
client refactored
YunchuWang Mar 19, 2025
0f79297
worker done
YunchuWang Mar 19, 2025
c7eb4f1
sample update
YunchuWang Mar 19, 2025
aa94d9c
fix
YunchuWang Mar 19, 2025
02f92ea
save
YunchuWang Mar 19, 2025
2b9d8eb
fix
YunchuWang Mar 19, 2025
3eca075
cleanup
YunchuWang Mar 19, 2025
6e9a6e8
cleanup
YunchuWang Mar 19, 2025
2f2a359
Merge branch 'main' into wangbill/update-proto
YunchuWang Mar 20, 2025
41ef360
Merge branch 'main' into wangbill/update-proto
YunchuWang Mar 20, 2025
d9e20ec
unit tests
YunchuWang Mar 20, 2025
f59af6b
Update Gradle build command to include stacktrace option for better d…
YunchuWang Mar 20, 2025
f7c5376
cleanup
YunchuWang Mar 20, 2025
538033c
Enhance build validation workflow to handle build failures by uploadi…
YunchuWang Mar 20, 2025
bb1fbb1
Update PATH_TO_TEST_JAVA_RUNTIME in build.gradle files to use environ…
YunchuWang Mar 21, 2025
637863c
Revert "Update PATH_TO_TEST_JAVA_RUNTIME in build.gradle files to use…
YunchuWang Mar 21, 2025
8d530cb
separate build and unit tests
YunchuWang Mar 21, 2025
5f3ebfb
use jdk11 for unit tests
YunchuWang Mar 21, 2025
02ec66d
update sample
YunchuWang Mar 21, 2025
f23edcc
clean up
YunchuWang Mar 21, 2025
299ab73
rename azuremanaged module names to avoid colliding module names name…
YunchuWang Mar 21, 2025
8cf6cdb
update azure managed to one package
YunchuWang Mar 21, 2025
1bebf5a
conn str support
YunchuWang Mar 23, 2025
98cf7eb
changelog
YunchuWang Mar 23, 2025
8705055
Add support for Visual Studio Code and Interactive Browser authentica…
YunchuWang Mar 24, 2025
ad72eca
Add support for IntelliJ authentication type in DurableTaskSchedulerC…
YunchuWang Mar 24, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion azuremanaged/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ plugins {

archivesBaseName = 'durabletask-azuremanaged'
group 'com.microsoft'
version = '1.5.0'
version = '1.5.0-preview.1'

def grpcVersion = '1.59.0'
def azureCoreVersion = '1.45.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ private DurableTaskSchedulerClientExtensions() {}
*
* @param builder The builder to configure.
* @param connectionString The connection string for Azure-managed Durable Task Scheduler.
* @param tokenCredential The token credential for authentication, or null to use connection string credentials.
* @throws NullPointerException if builder or connectionString is null
*/
public static void useDurableTaskScheduler(
DurableTaskGrpcClientBuilder builder,
String connectionString,
@Nullable TokenCredential tokenCredential) {
String connectionString) {
Objects.requireNonNull(builder, "builder must not be null");
Objects.requireNonNull(connectionString, "connectionString must not be null");

configureBuilder(builder,
DurableTaskSchedulerClientOptions.fromConnectionString(connectionString, tokenCredential));
DurableTaskSchedulerClientOptions.fromConnectionString(connectionString));
}

/**
Expand Down Expand Up @@ -64,16 +62,14 @@ public static void useDurableTaskScheduler(
* Creates a DurableTaskGrpcClientBuilder configured for Azure-managed Durable Task Scheduler using a connection string.
*
* @param connectionString The connection string for Azure-managed Durable Task Scheduler.
* @param tokenCredential The token credential for authentication, or null to use connection string credentials.
* @return A new configured DurableTaskGrpcClientBuilder instance.
* @throws NullPointerException if connectionString is null
*/
public static DurableTaskGrpcClientBuilder createClientBuilder(
String connectionString,
@Nullable TokenCredential tokenCredential) {
String connectionString) {
Objects.requireNonNull(connectionString, "connectionString must not be null");
return createBuilderFromOptions(
DurableTaskSchedulerClientOptions.fromConnectionString(connectionString, tokenCredential));
DurableTaskSchedulerClientOptions.fromConnectionString(connectionString));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.azure.core.credential.TokenCredential;
import com.azure.core.credential.TokenRequestContext;
import io.grpc.*;
import javax.annotation.Nullable;
import java.net.MalformedURLException;
import java.time.Duration;
import java.util.Objects;
Expand Down Expand Up @@ -34,12 +33,11 @@ public DurableTaskSchedulerClientOptions() {
* Creates a new instance of DurableTaskSchedulerClientOptions from a connection string.
*
* @param connectionString The connection string to parse.
* @param credential The credential to use for authentication. It is nullable for anonymous access.
* @return A new DurableTaskSchedulerClientOptions object.
*/
public static DurableTaskSchedulerClientOptions fromConnectionString(String connectionString, @Nullable TokenCredential credential) {
public static DurableTaskSchedulerClientOptions fromConnectionString(String connectionString) {
DurableTaskSchedulerConnectionString parsedConnectionString = new DurableTaskSchedulerConnectionString(connectionString);
return fromConnectionString(parsedConnectionString, credential);
return fromConnectionString(parsedConnectionString);
}

/**
Expand All @@ -48,13 +46,13 @@ public static DurableTaskSchedulerClientOptions fromConnectionString(String conn
* @param connectionString The parsed connection string.
* @return A new DurableTaskSchedulerClientOptions object.
*/
static DurableTaskSchedulerClientOptions fromConnectionString(DurableTaskSchedulerConnectionString connectionString, @Nullable TokenCredential credential) {
static DurableTaskSchedulerClientOptions fromConnectionString(DurableTaskSchedulerConnectionString connectionString) {
// TODO: Parse different credential types from connection string
DurableTaskSchedulerClientOptions options = new DurableTaskSchedulerClientOptions();
options.setEndpointAddress(connectionString.getEndpoint());
options.setTaskHubName(connectionString.getTaskHubName());
options.setCredential(credential);
options.setAllowInsecureCredentials(credential == null);
options.setCredential(connectionString.getCredential());
options.setAllowInsecureCredentials(options.getCredential() == null);
return options;
}

Expand Down Expand Up @@ -178,16 +176,6 @@ public DurableTaskSchedulerClientOptions setTokenRefreshMargin(Duration tokenRef
return this;
}

/**
* Validates that the options are properly configured.
*
* @throws IllegalArgumentException If the options are not properly configured.
*/
public void validate() {
Objects.requireNonNull(endpointAddress, "endpointAddress must not be null");
Objects.requireNonNull(taskHubName, "taskHubName must not be null");
}

/**
* Creates a gRPC channel using the configured options.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
import java.util.List;
import java.util.Map;

import javax.annotation.Nullable;

import com.azure.core.credential.TokenCredential;
import com.azure.identity.AzureCliCredentialBuilder;
import com.azure.identity.AzurePowerShellCredentialBuilder;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.identity.EnvironmentCredentialBuilder;
import com.azure.identity.ManagedIdentityCredentialBuilder;
import com.azure.identity.WorkloadIdentityCredentialBuilder;

/**
* Represents the constituent parts of a connection string for a Durable Task Scheduler service.
*/
Expand All @@ -27,9 +37,9 @@ public DurableTaskSchedulerConnectionString(String connectionString) {
this.properties = parseConnectionString(connectionString);

// Validate required properties
getRequiredValue("Endpoint");
getRequiredValue("Authentication");
getRequiredValue("TaskHub");
this.getAuthentication();
this.getTaskHubName();
this.getEndpoint();
}

/**
Expand Down Expand Up @@ -127,4 +137,54 @@ private static Map<String, String> parseConnectionString(String connectionString

return properties;
}

/**
* Gets a TokenCredential based on the authentication type specified in the connection string.
*
* @return A TokenCredential instance based on the specified authentication type, or null if authentication type is "none".
* @throws IllegalArgumentException If the connection string contains an unsupported authentication type.
*/
public @Nullable TokenCredential getCredential() {
String authType = getAuthentication();

// Parse the supported auth types in a case-insensitive way
switch (authType.toLowerCase().trim()) {
case "defaultazure":
return new DefaultAzureCredentialBuilder().build();
case "managedidentity":
return new ManagedIdentityCredentialBuilder().clientId(getClientId()).build();
case "workloadidentity":
WorkloadIdentityCredentialBuilder builder = new WorkloadIdentityCredentialBuilder();
if (getClientId() != null && !getClientId().isEmpty()) {
builder.clientId(getClientId());
}

if (getTenantId() != null && !getTenantId().isEmpty()) {
builder.tenantId(getTenantId());
}

if (getTokenFilePath() != null && !getTokenFilePath().isEmpty()) {
builder.tokenFilePath(getTokenFilePath());
}

if (getAdditionallyAllowedTenants() != null) {
for (String tenant : getAdditionallyAllowedTenants()) {
builder.additionallyAllowedTenants(tenant);
}
}

return builder.build();
case "environment":
return new EnvironmentCredentialBuilder().build();
case "azurecli":
return new AzureCliCredentialBuilder().build();
case "azurepowershell":
return new AzurePowerShellCredentialBuilder().build();
case "none":
return null;
default:
throw new IllegalArgumentException(
String.format("The connection string contains an unsupported authentication type '%s'.", authType));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,16 @@ private DurableTaskSchedulerWorkerExtensions() {}
*
* @param builder The builder to configure.
* @param connectionString The connection string for Azure-managed Durable Task Scheduler.
* @param tokenCredential The token credential for authentication, or null to use connection string credentials.
* @throws NullPointerException if builder or connectionString is null
*/
public static void useDurableTaskScheduler(
DurableTaskGrpcWorkerBuilder builder,
String connectionString,
@Nullable TokenCredential tokenCredential) {
String connectionString) {
Objects.requireNonNull(builder, "builder must not be null");
Objects.requireNonNull(connectionString, "connectionString must not be null");

configureBuilder(builder,
DurableTaskSchedulerWorkerOptions.fromConnectionString(connectionString, tokenCredential));
DurableTaskSchedulerWorkerOptions.fromConnectionString(connectionString));
}

/**
Expand Down Expand Up @@ -64,16 +62,14 @@ public static void useDurableTaskScheduler(
* Creates a DurableTaskGrpcWorkerBuilder configured for Azure-managed Durable Task Scheduler using a connection string.
*
* @param connectionString The connection string for Azure-managed Durable Task Scheduler.
* @param tokenCredential The token credential for authentication, or null to use connection string credentials.
* @return A new configured DurableTaskGrpcWorkerBuilder instance.
* @throws NullPointerException if connectionString is null
*/
public static DurableTaskGrpcWorkerBuilder createWorkerBuilder(
String connectionString,
@Nullable TokenCredential tokenCredential) {
String connectionString) {
Objects.requireNonNull(connectionString, "connectionString must not be null");
return createBuilderFromOptions(
DurableTaskSchedulerWorkerOptions.fromConnectionString(connectionString, tokenCredential));
DurableTaskSchedulerWorkerOptions.fromConnectionString(connectionString));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.Objects;
import java.net.URL;
import java.net.MalformedURLException;
import javax.annotation.Nullable;

/**
* Options for configuring the Durable Task Scheduler worker.
Expand All @@ -45,27 +44,25 @@ public DurableTaskSchedulerWorkerOptions() {
* Creates a new instance of DurableTaskSchedulerWorkerOptions from a connection string.
*
* @param connectionString The connection string to parse.
* @param credential The token credential for authentication, or null to use connection string credentials.
* @return A new DurableTaskSchedulerWorkerOptions object.
*/
public static DurableTaskSchedulerWorkerOptions fromConnectionString(String connectionString, @Nullable TokenCredential credential) {
public static DurableTaskSchedulerWorkerOptions fromConnectionString(String connectionString) {
DurableTaskSchedulerConnectionString parsedConnectionString = new DurableTaskSchedulerConnectionString(connectionString);
return fromConnectionString(parsedConnectionString, credential);
return fromConnectionString(parsedConnectionString);
}

/**
* Creates a new instance of DurableTaskSchedulerWorkerOptions from a parsed connection string.
*
* @param connectionString The parsed connection string.
* @param credential The token credential for authentication, or null to use connection string credentials.
* @return A new DurableTaskSchedulerWorkerOptions object.
*/
static DurableTaskSchedulerWorkerOptions fromConnectionString(DurableTaskSchedulerConnectionString connectionString, @Nullable TokenCredential credential) {
static DurableTaskSchedulerWorkerOptions fromConnectionString(DurableTaskSchedulerConnectionString connectionString) {
DurableTaskSchedulerWorkerOptions options = new DurableTaskSchedulerWorkerOptions();
options.setEndpointAddress(connectionString.getEndpoint());
options.setTaskHubName(connectionString.getTaskHubName());
options.setCredential(credential);
options.setAllowInsecureCredentials(credential == null);
options.setCredential(connectionString.getCredential());
options.setAllowInsecureCredentials(options.getCredential() == null);
return options;
}

Expand Down Expand Up @@ -189,16 +186,6 @@ public DurableTaskSchedulerWorkerOptions setTokenRefreshMargin(Duration tokenRef
return this;
}

/**
* Validates that the options are properly configured.
*
* @throws IllegalArgumentException If the options are not properly configured.
*/
public void validate() {
Objects.requireNonNull(endpointAddress, "endpointAddress must not be null");
Objects.requireNonNull(taskHubName, "taskHubName must not be null");
}

/**
* Creates a gRPC channel using the configured options.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void useDurableTaskScheduler_WithConnectionString_ConfiguresBuilder() {

// Act
DurableTaskSchedulerClientExtensions.useDurableTaskScheduler(
mockBuilder, VALID_CONNECTION_STRING, mockCredential);
mockBuilder, VALID_CONNECTION_STRING);

// Assert
verify(mockBuilder).grpcChannel(any(Channel.class));
Expand All @@ -49,7 +49,7 @@ public void useDurableTaskScheduler_WithConnectionString_ThrowsForNullBuilder()
// Act & Assert
assertThrows(NullPointerException.class,
() -> DurableTaskSchedulerClientExtensions.useDurableTaskScheduler(
null, VALID_CONNECTION_STRING, mockCredential));
null, VALID_CONNECTION_STRING));
}

@Test
Expand All @@ -58,7 +58,7 @@ public void useDurableTaskScheduler_WithConnectionString_ThrowsForNullConnection
// Act & Assert
assertThrows(NullPointerException.class,
() -> DurableTaskSchedulerClientExtensions.useDurableTaskScheduler(
mockBuilder, null, mockCredential));
mockBuilder, null));
}

@Test
Expand Down Expand Up @@ -107,7 +107,7 @@ public void useDurableTaskScheduler_WithExplicitParameters_ThrowsForNullTaskHubN
public void createClientBuilder_WithConnectionString_CreatesValidBuilder() {
// Act
DurableTaskGrpcClientBuilder result =
DurableTaskSchedulerClientExtensions.createClientBuilder(VALID_CONNECTION_STRING, mockCredential);
DurableTaskSchedulerClientExtensions.createClientBuilder(VALID_CONNECTION_STRING);

// Assert
assertNotNull(result);
Expand All @@ -118,7 +118,7 @@ public void createClientBuilder_WithConnectionString_CreatesValidBuilder() {
public void createClientBuilder_WithConnectionString_ThrowsForNullConnectionString() {
// Act & Assert
assertThrows(NullPointerException.class,
() -> DurableTaskSchedulerClientExtensions.createClientBuilder(null, mockCredential));
() -> DurableTaskSchedulerClientExtensions.createClientBuilder(null));
}

@Test
Expand Down
Loading
Loading