Search code examples
azureazure-data-factoryazure-resource-managerazure-managed-identityazure-bicep

Bicep - create credentials for Managed Identity for use in LinkedService


I am attempting to re-create an Azure Data Factory using Bicep, and specifically i am trying to user a User Assigned Managed Identity for a linked service to an Azure SQL Database.

I am able to create the ua MI by doing the following -

resource uami 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-11-30' = {
    name: uamiName
    location: location

  }

This gets successfully attached to the data factory upon build.

Next i am trying to associate that UA MI to the database connection i am making in the Linked Services section. In the front end its like selected 'User Assigned Managed Identity' and selecting the creds ( or create new). I am trying to do this via Bicep and In order to do this, i first needs credentials - I can't find anywhere in Bicep to create these credentials.

enter image description here

I see lots of old references to Microsoft.DataFactory/factories/credentials - but i can't seem to find that.

Appreciate any help that anyone can offer.


Solution

  • I haven't found much documentation neither.
    I've created a credential from data factory studio then export the ARM template. The bicep equivalent looks like that:

    param location string
    param uamiName string
    param dataFactoryName string
    
    // Create the managed identity
    resource uami 'Microsoft.ManagedIdentity/userAssignedIdentities@2022-01-31-preview' = {
      name: uamiName
      location: location
    }
    
    // assuming the data factory already exists
    resource dataFactory 'Microsoft.DataFactory/factories@2018-06-01' existing = {
      name: dataFactoryName
    }
    
    // Create the credentials
    resource credentials 'Microsoft.DataFactory/factories/credentials@2018-06-01' = {
      name: uami.name
      parent: dataFactory
      properties: {
        type: 'ManagedIdentity'
        typeProperties: {
          resourceId: uami.id
        }
      }
    }