0

Unable to find any function to get the authentication key for SHIR

            `ArmClient armClient = new ArmClient(
                new ClientSecretCredential(tenantId, clientId, clientSecret,
                new TokenCredentialOptions
                {
                    AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
                }),
                subscriptionId,
                new ArmClientOptions { Environment = ArmEnvironment.AzurePublicCloud });

            ResourceIdentifier resourceIdentifier = SubscriptionResource.CreateResourceIdentifier(subscriptionId);

            SubscriptionResource subscriptionResource = armClient.GetSubscriptionResource(resourceIdentifier);
            var resourceGroupOperation = subscriptionResource.GetResourceGroups().Get(resourceGroupName);

            ResourceGroupResource resourceGroupResource = resourceGroupOperation.Value;

            DataFactoryData dataFactoryData = new DataFactoryData(AzureLocation.EastUS);

            var dataFactoryOperation = resourceGroupResource.GetDataFactories().CreateOrUpdate(WaitUntil.Completed, dataFactoryName, dataFactoryData);
            DataFactoryResource dataFactoryResource = dataFactoryOperation.Value;
            var dataFactoryIntegrationRuntimeData = new DataFactoryIntegrationRuntimeData(
                new SelfHostedIntegrationRuntime
                {
                    Description = "A self-hosted integration runtime from C# Azure SDK",
                });
            var createOrUpdateOperation = dataFactoryResource.GetDataFactoryIntegrationRuntimes().CreateOrUpdate(
                WaitUntil.Completed,
                integrationRuntimeName,
                dataFactoryIntegrationRuntimeData);
            Console.WriteLine(createOrUpdateOperation.WaitForCompletionResponse().Content);

what i am looking for is to get the keys var keys = dataFactoryResource.GetDataFactoryIntegrationRuntime(integrationRuntimeName); This is the python function for auth keys

auth_keys = adf_client.integration_runtimes.list_auth_keys(
        resource_group_name=rg_name,
        factory_name=df_name,
        integration_runtime_name=ir_name,
    )`

1 Answer 1

0

Self-Hosted Integration Runtime cannot find the auth key using the Azure.ResourceManager.DataFactory SDK package.

You can use the code below to obtain the auth key for Self-Hosted Integration Runtime using the Azure.ResourceManager.DataFactory SDK package.

Code:

var integrationRuntimeOperation = dataFactoryResource.GetDataFactoryIntegrationRuntime(integrationRuntimeName);
var integrationRuntimeResource = integrationRuntimeOperation.Value;
var authKeysOperation = integrationRuntimeResource.GetAuthKeys();
var authKeys = authKeysOperation.Value;
Console.WriteLine($"Auth key 1: {authKeys.AuthKey1}");
Console.WriteLine($"Auth key 2: {authKeys.AuthKey2}");

The code above retrieves the auth keys for Self-Hosted Integration Runtime.

Here is the full code to create and obtain the necessary process.

Code:

using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.DataFactory.Models;
using Azure.ResourceManager.DataFactory;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager;
using Azure;

ArmClient armClient = new ArmClient(
                new ClientSecretCredential(tenantId, clientId, clientSecret,
                new TokenCredentialOptions
                {
                    AuthorityHost = AzureAuthorityHosts.AzurePublicCloud
                }),
                subscriptionId,
                new ArmClientOptions { Environment = ArmEnvironment.AzurePublicCloud });

            ResourceIdentifier resourceIdentifier = SubscriptionResource.CreateResourceIdentifier(subscriptionId);

            SubscriptionResource subscriptionResource = armClient.GetSubscriptionResource(resourceIdentifier);
            var resourceGroupOperation = subscriptionResource.GetResourceGroups().Get(resourceGroupName);

            ResourceGroupResource resourceGroupResource = resourceGroupOperation.Value;

            DataFactoryData dataFactoryData = new DataFactoryData(AzureLocation.EastUS);

            var dataFactoryOperation = resourceGroupResource.GetDataFactories().CreateOrUpdate(WaitUntil.Completed, dataFactoryName, dataFactoryData);
            DataFactoryResource dataFactoryResource = dataFactoryOperation.Value;
            var dataFactoryIntegrationRuntimeData = new DataFactoryIntegrationRuntimeData(
                new SelfHostedIntegrationRuntime
                {
                    Description = "A self-hosted integration runtime from C# Azure SDK",
                });
            var createOrUpdateOperation = dataFactoryResource.GetDataFactoryIntegrationRuntimes().CreateOrUpdate(
                WaitUntil.Completed,
                integrationRuntimeName,
                dataFactoryIntegrationRuntimeData);
            Console.WriteLine(createOrUpdateOperation.WaitForCompletionResponse().Content);

var integrationRuntimeOperation = dataFactoryResource.GetDataFactoryIntegrationRuntime(integrationRuntimeName);
var integrationRuntimeResource = integrationRuntimeOperation.Value;
var authKeysOperation = integrationRuntimeResource.GetAuthKeys();
var authKeys = authKeysOperation.Value;
Console.WriteLine($"Auth key 1: {authKeys.AuthKey1}");
Console.WriteLine($"Auth key 2: {authKeys.AuthKey2}");

Output:

{
  "id": "/subscriptions/xxxxxx/resourceGroups/xxxx/providers/Microsoft.DataFactory/factories/venkatdata326/integrationruntimes/myIntegrationRuntime",
  "name": "myIntegrationRuntime",
  "type": "Microsoft.DataFactory/factories/integrationruntimes",
  "properties": {
    "type": "SelfHosted",
    "description": "A self-hosted integration runtime from C# Azure SDK",
    "typeProperties": {}
  },
  "etag": "a900xxxxe0000"
}
Auth key 1: IR@07bxxxxf69-24c5711401b5@venkatdata326@ServiceEndpoint=venkatdata326.eastus.datafactory.azure.net@T0ekLxxxxx+Q=
Auth key 2: IR@07xxxxxxf69-24c5711401b5@venkatdata326@ServiceEndpoint=venkatdata326.eastus.datafactory.azure.net@RPNnqBy5xxxxxxbDNBdbKg=

enter image description here

Reference:

azure-sdk-for-net/sdk/datafactory/Azure.ResourceManager.DataFactory at Azure.ResourceManager.DataFactory_1.0.0-beta.3 · Azure/azure-sdk-for-net · GitHub

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.