skip to Main Content

There is the article about adding credentials in Azure Data Factory: https://learn.microsoft.com/en-us/azure/data-factory/credentials?tabs=data-factory

Associate the user-assigned managed identity to the data factory instance using Azure portal, SDK, PowerShell, REST API.

I am interested in PowerShell or REST API option, the process need to be automated.

I have found New-AzDataFactoryV2LinkedServiceEncryptedCredential in documentation https://learn.microsoft.com/en-us/powershell/module/az.datafactory/new-azdatafactoryv2linkedserviceencryptedcredential?view=azps-8.1.0 but it doesn’t like what I am looking for.

Does anyone have an example of PowerShell code or REST API endpoints to add credential to Azure Data Factory?

Edit:
I am reffering to this credentials:
enter image description here

2

Answers


  1. Please follow below reference it has detail explanation about:

    Creating credentials in azure data factory using Power shell and REST API.

    Reference:

    Azure Data Factory Using PowerShell by Dhilasu reddy

    Managed identity for Azure Data Factory and Azure Synapse | Microsoft

    Login or Signup to reply.
  2. I cannot see anything yet supported for terraform or for the az cli, however there is a REST API.
    https://learn.microsoft.com/en-us/rest/api/datafactory/credential-operations

    you can then use this with the az cli rest call e.g.

    $data_factory_name="my-data-factory"
    $resource_group_name="my-resource-group"
    $subscription_id=$(az account show --query "id")
    $mi_name="my-user-managed-identity"
    $credential_name="$mi_name"
    
    $mi_id=$(az identity show --name $mi_name --subscription $subscription_id --resource-group $resource_group_name --query "id" -o tsv)
    
    $url="https://management.azure.com/subscriptions/$subscription_id/resourceGroups/$resource_group_name/providers/Microsoft.DataFactory/factories/$data_factory_name/credentials/$credential_name`?api-version=2018-06-01"
    
    $body=[PSCustomObject]@{
      properties = @{
        "type" = "ManagedIdentity"
        "typeProperties" = @{
          "resourceId" = $mi_id
        }
      }
    }
    $bodyJson = $body | ConvertTo-Json -Compress -Depth 100
    $bodyJson = $bodyJson -replace "`"", "`""
    
    az rest --method put --url $url --body $bodyJson
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search