Skip to content

Commit 6b2df44

Browse files
authored
Merge pull request #3 from shsagir/ad-hoc
Add snippets for zonal migration
2 parents d1634b9 + 8a20808 commit 6b2df44

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Azure.Core;
2+
using Azure.ResourceManager.Kusto;
3+
using Azure.ResourceManager.Kusto.Models;
4+
using ArmClient = Azure.ResourceManager.ArmClient;
5+
using ClientSecretCredential = Azure.Identity.ClientSecretCredential;
6+
using WaitUntil = Azure.WaitUntil;
7+
8+
var tenantId = "{tenantId}";
9+
var clientId = "{clientId}";
10+
var clientSecret = "{clientSecret}";
11+
var subscriptionId = "{subscriptionId}";
12+
var resourceGroupName = "{resourceGroupName}";
13+
var clusterName = "{clusterName}";
14+
15+
var credentials = new ClientSecretCredential(tenantId, clientId, clientSecret);
16+
var resourceManagementClient = new ArmClient(credentials, subscriptionId);
17+
var resourceIdentifier = new ResourceIdentifier($"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kusto/Clusters/{clusterName}");
18+
var cluster = resourceManagementClient.GetKustoClusterResource(resourceIdentifier);
19+
20+
var kustoClusterPatch = new KustoClusterPatch(AzureLocation.NorthEurope);
21+
kustoClusterPatch.Zones.Clear();
22+
kustoClusterPatch.Zones.Add("1");
23+
kustoClusterPatch.Zones.Add("2");
24+
kustoClusterPatch.Zones.Add("3");
25+
26+
var armOperation = await cluster.UpdateAsync(WaitUntil.Started, kustoClusterPatch).ConfigureAwait(false);
27+
28+
var response = armOperation.UpdateStatus();
29+
Console.WriteLine($"ClientRequestId: {response.ClientRequestId}");
30+
31+
while (true)
32+
{
33+
Console.WriteLine($"{DateTime.UtcNow:o} {response.Status, -5} {response.ReasonPhrase}");
34+
if (armOperation.HasCompleted)
35+
break;
36+
37+
await Task.Delay(60000).ConfigureAwait(false);
38+
response = await armOperation.UpdateStatusAsync().ConfigureAwait(false);
39+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"clusters_clusterName_name": {
6+
"defaultValue": "clusterName",
7+
"type": "string"
8+
}
9+
},
10+
"variables": {},
11+
"resources": [
12+
{
13+
"type": "Microsoft.Kusto/clusters",
14+
"apiVersion": "2023-05-02",
15+
"name": "[parameters('clusters_clusterName_name')]",
16+
"location": "North Europe",
17+
"sku": {
18+
"name": "{skuName}",
19+
"tier": "Basic",
20+
"capacity": 1
21+
},
22+
"zones": ["1","2","3"],
23+
"identity": {
24+
"type": "SystemAssigned"
25+
},
26+
"properties": {
27+
"trustedExternalTenants": [],
28+
"enableDiskEncryption": false,
29+
"enableStreamingIngest": false,
30+
"languageExtensions": {
31+
"value": []
32+
},
33+
"enablePurge": false,
34+
"enableDoubleEncryption": false,
35+
"engineType": "V3",
36+
"acceptedAudiences": [],
37+
"restrictOutboundNetworkAccess": "Disabled",
38+
"allowedFqdnList": [],
39+
"publicNetworkAccess": "Enabled",
40+
"allowedIpRangeList": [],
41+
"enableAutoStop": true,
42+
"publicIPType": "IPv4"
43+
}
44+
}
45+
]
46+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from azure.identity import DefaultAzureCredential
2+
from azure.mgmt.kusto import KustoManagementClient
3+
from azure.mgmt.kusto import models
4+
import time
5+
from azure.core.exceptions import HttpResponseError
6+
7+
subscription_id = "{subscriptionId}"
8+
resource_group_name = "{resourceGroupName}"
9+
cluster_name = "{clusterName}"
10+
11+
client = KustoManagementClient(DefaultAzureCredential(), subscription_id)
12+
lro_poller = client.clusters.begin_update(resource_group_name, cluster_name, models.ClusterUpdate.from_dict({"zones": ["1", "2", "3"]}))
13+
14+
while (not(lro_poller.done())):
15+
time.sleep(60)
16+
17+
print (f"status: {lro_poller.status()}")
18+
19+
try:
20+
lro_poller.result()
21+
except HttpResponseError as e:
22+
print (f"Exception: {e}")

0 commit comments

Comments
 (0)