@@ -3,7 +3,7 @@ title: Use follower database feature to attach databases in Azure Data Explorer
33description : Learn about how to attach databases in Azure Data Explorer using the follower database feature.
44ms.reviewer : gabilehner
55ms.topic : how-to
6- ms.date : 06/10 /2025
6+ ms.date : 12/11 /2025
77ms.custom :
88 - devx-track-azurepowershell
99 - sfi-image-nochange
@@ -99,29 +99,22 @@ You can optionally make the database name in the follower cluster different from
9999### C\# example
100100
101101``` csharp
102- var tenantId = " xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx" ; // Directory (tenant) ID
103- var clientId = " xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx" ; // Application ID
104- var clientSecret = " PlaceholderClientSecret" ; // Client Secret
105- var followerSubscriptionId = " xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx" ;
106- var credentials = new ClientSecretCredential (tenantId , clientId , clientSecret );
107- var resourceManagementClient = new ArmClient (credentials , followerSubscriptionId );
108- var followerResourceGroupName = " followerResourceGroup" ;
109- var followerClusterName = " follower" ;
110- var subscription = await resourceManagementClient .GetDefaultSubscriptionAsync ();
111- var resourceGroup = (await subscription .GetResourceGroupAsync (followerResourceGroupName )).Value ;
112- var cluster = (await resourceGroup .GetKustoClusterAsync (followerClusterName )).Value ;
113- var attachedDatabaseConfigurations = cluster .GetKustoAttachedDatabaseConfigurations ();
114- var attachedDatabaseConfigurationName = " attachedDatabaseConfiguration"
115- var leaderSubscriptionId = " xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx" ;
116- var leaderResourceGroup = " leaderResourceGroup" ;
117- var leaderClusterName = " leader" ;
102+ var followerClusterId = KustoClusterResource .CreateResourceIdentifier (subscriptionId : " xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx" , resourceGroupName : " followerResourceGroup" , clusterName : " follower" );
103+ var leaderClusterId = KustoClusterResource .CreateResourceIdentifier (subscriptionId : " xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx" , resourceGroupName : " leaderResourceGroup" , clusterName : " leader" );
104+ var attachedDatabaseConfigurationName = " attachedDatabaseConfiguration" ;
105+
106+ var credentials = new ManagedIdentityCredential ();
107+ var resourceManagementClient = new ArmClient (credentials );
108+ var followerCluster = resourceManagementClient .GetKustoClusterResource (followerClusterId );
109+ var attachedDatabaseConfigurations = followerCluster .GetKustoAttachedDatabaseConfigurations ();
118110var attachedDatabaseConfigurationData = new KustoAttachedDatabaseConfigurationData
119111{
120- ClusterResourceId = new ResourceIdentifier ( $" /subscriptions/{ leaderSubscriptionId }/resourceGroups/{ leaderResourceGroup }/providers/Microsoft.Kusto/Clusters/{ leaderClusterName } " ) ,
112+ ClusterResourceId = leaderClusterId ,
121113 DatabaseName = " <databaseName>" , // Can be a specific database name in a leader cluster or * for all databases
122114 DefaultPrincipalsModificationKind = KustoDatabaseDefaultPrincipalsModificationKind .Union ,
123115 Location = AzureLocation .NorthCentralUS
124116};
117+
125118// Table level sharing properties are not supported when using '*' all databases notation.
126119if (attachedDatabaseConfigurationData .DatabaseName != " *" )
127120{
@@ -136,6 +129,7 @@ if (attachedDatabaseConfigurationData.DatabaseName != "*")
136129 attachedDatabaseConfigurationData .TableLevelSharingProperties .FunctionsToInclude .Add (" func1" );
137130 attachedDatabaseConfigurationData .TableLevelSharingProperties .FunctionsToExclude .Add (" func2" );
138131}
132+
139133await attachedDatabaseConfigurations .CreateOrUpdateAsync (WaitUntil .Completed , attachedDatabaseConfigurationName , attachedDatabaseConfigurationData );
140134```
141135
@@ -447,20 +441,12 @@ To verify that the database was successfully attached, find your attached databa
447441The follower cluster can detach any attached follower database as follows:
448442
449443```csharp
450- var tenantId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx"; //Directory (tenant) ID
451- var clientId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx"; //Application ID
452- var clientSecret = "PlaceholderClientSecret"; //Client Secret
453- var followerSubscriptionId = "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx";
454- var credentials = new ClientSecretCredential(tenantId, clientId, clientSecret);
455- var resourceManagementClient = new ArmClient(credentials, followerSubscriptionId);
456- var followerResourceGroupName = "testrg";
457- //The cluster and database attached database configuration are created as part of the prerequisites
458- var followerClusterName = "follower";
459- var attachedDatabaseConfigurationsName = "attachedDatabaseConfiguration";
460- var subscription = await resourceManagementClient.GetDefaultSubscriptionAsync();
461- var resourceGroup = (await subscription.GetResourceGroupAsync(followerResourceGroupName)).Value;
462- var cluster = (await resourceGroup.GetKustoClusterAsync(followerClusterName)).Value;
463- var attachedDatabaseConfiguration = (await cluster.GetKustoAttachedDatabaseConfigurationAsync(attachedDatabaseConfigurationsName)).Value;
444+ var attachedDatabaseConfigurationId = KustoAttachedDatabaseConfigurationResource.CreateResourceIdentifier(
445+ subscriptionId: "xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx", resourceGroupName: "testrg", clusterName: "follower",
446+ attachedDatabaseConfigurationName: "attachedDatabaseConfiguration");
447+ var credentials = new ManagedIdentityCredential();
448+ var resourceManagementClient = new ArmClient(credentials);
449+ var attachedDatabaseConfiguration = resourceManagementClient.GetKustoAttachedDatabaseConfigurationResource(attachedDatabaseConfigurationId);
464450await attachedDatabaseConfiguration.DeleteAsync(WaitUntil.Completed);
465451```
466452
@@ -469,27 +455,16 @@ await attachedDatabaseConfiguration.DeleteAsync(WaitUntil.Completed);
469455The leader cluster can detach any attached database as follows:
470456
471457``` csharp
472- var tenantId = " xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx" ; // Directory (tenant) ID
473- var clientId = " xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx" ; // Application ID
474- var clientSecret = " PlaceholderClientSecret" ; // Client Secret
475- var leaderSubscriptionId = " xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx" ;
476- var credentials = new ClientSecretCredential (tenantId , clientId , clientSecret );
477- var resourceManagementClient = new ArmClient (credentials , leaderSubscriptionId );
478- var leaderResourceGroupName = " testrg" ;
479- var leaderClusterName = " leader" ;
480- var subscription = await resourceManagementClient .GetDefaultSubscriptionAsync ();
481- var resourceGroup = (await subscription .GetResourceGroupAsync (leaderResourceGroupName )).Value ;
482- var cluster = (await resourceGroup .GetKustoClusterAsync (leaderClusterName )).Value ;
483- var followerSubscriptionId = " xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx" ;
484- var followerResourceGroupName = " followerResourceGroup" ;
485- // The cluster and attached database configuration that are created as part of the Prerequisites
486- var followerClusterName = " follower" ;
487- var attachedDatabaseConfigurationsName = " attachedDatabaseConfiguration" ;
458+ var leaderClusterId = KustoClusterResource .CreateResourceIdentifier (subscriptionId : " xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx" , resourceGroupName : " testrg" , clusterName : " leader" );
459+ var followerClusterId = KustoClusterResource .CreateResourceIdentifier (subscriptionId : " xxxxxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx" , resourceGroupName : " followerResourceGroup" , clusterName : " follower" );
488460var followerDatabaseDefinition = new KustoFollowerDatabaseDefinition (
489- clusterResourceId : new ResourceIdentifier ( $" /subscriptions/{ followerSubscriptionId }/resourceGroups/{ followerResourceGroupName }/providers/Microsoft.Kusto/Clusters/{ followerClusterName } " ) ,
490- attachedDatabaseConfigurationName : attachedDatabaseConfigurationsName
461+ clusterResourceId : followerClusterId ,
462+ attachedDatabaseConfigurationName : " attachedDatabaseConfiguration "
491463);
492- await cluster .DetachFollowerDatabasesAsync (WaitUntil .Completed , followerDatabaseDefinition );
464+ var credentials = new ManagedIdentityCredential ();
465+ var resourceManagementClient = new ArmClient (credentials );
466+ var leaderCluster = resourceManagementClient .GetKustoClusterResource (leaderClusterId );
467+ await leaderCluster .DetachFollowerDatabasesAsync (WaitUntil .Completed , followerDatabaseDefinition );
493468```
494469
495470## [ Python] ( #tab/python )
0 commit comments