Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
BartHuls
Helper I
Helper I

Does the DataSource / UpdateDatasourceRequest support a connection based on Managed Identities

Does the DataSource / UpdateDatasourceRequest support a connection based on Managed Identities
I have now the connection based on UserCode / Password

 // Create UpdateDatasourceRequest to update Azure SQL datasource credentials
      var updateDatasourceRequest = new UpdateDatasourceRequest
      {
          CredentialDetails = new CredentialDetails(
              new BasicCredentials(userName, password),
              PrivacyLevel.None,
              EncryptedConnection.NotEncrypted)
      };


Thanks in advance for your remarks
 

1 ACCEPTED SOLUTION
v-dineshya
Community Support
Community Support

Hi @BartHuls ,

Thank you for reaching out to the Microsoft Community Forum.

 

Yes, the UpdateDatasourceRequest in the Power BI .NET SDK does support using Managed Identities, but there are important configurations required.


To use Managed Identity authentication (System or User Assigned) with an Azure SQL Database or other supported services, your request must:

1. Use the correct CredentialDetails with OAuth2Credentials.
2. Set the appropriate CredentialType as OAuth2.
3. The data source must support OAuth2 for Azure Active Directory authentication (which Azure SQL does).

Example: Using Managed Identity with Azure SQL

Here’s how you could structure your UpdateDatasourceRequest to use Managed Identity:

var updateDatasourceRequest = new UpdateDatasourceRequest
{
CredentialDetails = new CredentialDetails
{
CredentialType = "OAuth2",
Credentials = new OAuth2Credentials
{
// Use "system" for system-assigned identity or provide client ID for user-assigned
Identity = new OAuth2Identity
{
Type = "ManagedIdentity",
// For user-assigned identity, use ClientId:
// ClientId = "<your-user-assigned-client-id>"
}
},
PrivacyLevel = "None",
EncryptedConnection = "Encrypted"
}
};

Note:
1.CredentialType = "OAuth2" is required for Managed Identity.
2.OAuth2Credentials.Identity.Type should be "ManagedIdentity".
3.If you're using a user-assigned managed identity, you'll need to include the ClientId.
4.The service principal or managed identity must have appropriate access to the data source, e.g., be granted access to Azure SQL DB with AzureAD Integrated authentication mode.

 

Please refer community thread and articles.

Solved: How to set a dataconnection of a DataSet - Microsoft Fabric Community

UpdateDatasourceRequest.CredentialDetails Property (Microsoft.PowerBI.Api.Models) - Azure for .NET D...

UpdateDatasourceRequest Class (Microsoft.PowerBI.Api.Models) - Azure for .NET Developers | Microsoft...

Managed identities for Azure resources - Managed identities for Azure resources | Microsoft Learn

Managed identities for Azure - Azure Service Fabric | Microsoft Learn

Managed identities for Azure resources frequently asked questions - Managed identities for Azure res...

Azure Services with managed identities support - Managed identities for Azure resources | Microsoft ...

 

If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.

 

Thank you

View solution in original post

10 REPLIES 10
v-dineshya
Community Support
Community Support

Hi @BartHuls ,

Thank you for reaching out to the Microsoft Community Forum.

 

Yes, the UpdateDatasourceRequest in the Power BI .NET SDK does support using Managed Identities, but there are important configurations required.


To use Managed Identity authentication (System or User Assigned) with an Azure SQL Database or other supported services, your request must:

1. Use the correct CredentialDetails with OAuth2Credentials.
2. Set the appropriate CredentialType as OAuth2.
3. The data source must support OAuth2 for Azure Active Directory authentication (which Azure SQL does).

Example: Using Managed Identity with Azure SQL

Here’s how you could structure your UpdateDatasourceRequest to use Managed Identity:

var updateDatasourceRequest = new UpdateDatasourceRequest
{
CredentialDetails = new CredentialDetails
{
CredentialType = "OAuth2",
Credentials = new OAuth2Credentials
{
// Use "system" for system-assigned identity or provide client ID for user-assigned
Identity = new OAuth2Identity
{
Type = "ManagedIdentity",
// For user-assigned identity, use ClientId:
// ClientId = "<your-user-assigned-client-id>"
}
},
PrivacyLevel = "None",
EncryptedConnection = "Encrypted"
}
};

Note:
1.CredentialType = "OAuth2" is required for Managed Identity.
2.OAuth2Credentials.Identity.Type should be "ManagedIdentity".
3.If you're using a user-assigned managed identity, you'll need to include the ClientId.
4.The service principal or managed identity must have appropriate access to the data source, e.g., be granted access to Azure SQL DB with AzureAD Integrated authentication mode.

 

Please refer community thread and articles.

Solved: How to set a dataconnection of a DataSet - Microsoft Fabric Community

UpdateDatasourceRequest.CredentialDetails Property (Microsoft.PowerBI.Api.Models) - Azure for .NET D...

UpdateDatasourceRequest Class (Microsoft.PowerBI.Api.Models) - Azure for .NET Developers | Microsoft...

Managed identities for Azure resources - Managed identities for Azure resources | Microsoft Learn

Managed identities for Azure - Azure Service Fabric | Microsoft Learn

Managed identities for Azure resources frequently asked questions - Managed identities for Azure res...

Azure Services with managed identities support - Managed identities for Azure resources | Microsoft ...

 

If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.

 

Thank you

Hi @BartHuls ,

If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.

 

Thank you

Hi @BartHuls ,

If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.

 

Thank you

Hi @BartHuls ,

If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.

 

Thank you

v-dineshya
Community Support
Community Support

Hi  @BartHuls ,

Thanks for reaching out to the Microsoft fabric community forum.

 

Can you please provide more details on your Query?. Which environment are you trying to connect? Whether it is Azure platform or Microsoft Fabric?

 

If you find this post helpful, please mark it as an "Accept as Solution" and consider giving a KUDOS. Feel free to reach out if you need further assistance.
Thanks and Regards

 

Hi @BartHuls ,

 

We haven’t heard from you on the last response and was just checking back to see if your query got answered. Otherwise, will respond back with the more details and we will try to help.

 

Thank you

Hi @BartHuls ,

Can you please provide more details on your Query?. Which environment are you trying to connect? Whether it is Azure platform or Microsoft Fabric?. I am from Microsoft Fabric community. If your issue is related to Microsoft fabric , we will provide solution for your query. For questions specifically related to Azure, I recommend posting in the dedicated Azure forum https://learn.microsoft.com/en-us/answers/questions/ask/, where specialists in that area can better assist you.

 

Thanks

Hi @BartHuls ,

Can you please provide more details on your Query?. Which environment are you trying to connect? Whether it is Azure platform or Microsoft Fabric?. I am from Microsoft Fabric community. If your issue is related to Microsoft fabric , we will provide solution for your query. For questions specifically related to Azure, I recommend posting in the dedicated Azure forum https://learn.microsoft.com/en-us/answers/questions/ask/, where specialists in that area can better assist you.

 

Thanks

BartHuls
Helper I
Helper I

No  there is no Hypothetical class ManagedIdentityCredentials. So I assume no

v-priyankata
Community Support
Community Support

Hi @BartHuls ,

 

Thank you for reaching out to the Microsoft Community Forum.

 

The UpdateDatasourceRequest in Azure SDKs, especially when dealing with services like Power BI or Azure Data Factory, typically supports different authentication methods. While your current implementation uses BasicCredentials with a username and password, Managed Identity authentication is also supported in many Azure SDKs.

 

However, the support for Managed Identity depends on the specific API or SDK you’re using. For Azure Data Factory, for instance, Managed Identity is supported, but for Power BI REST API, the support is more limited and typically relies on OAuth 2.0.

 

Steps to approach this

 

1. Check SDK Documentation: Verify if your SDK version supports Managed Identity for the UpdateDatasourceRequest.

 

2. Azure Identity Library: Use the Azure Identity library to acquire tokens using Managed Identity.

 

3. If you're using the Azure SDK for .NET, use the below code .

 

var credential = new DefaultAzureCredential(); // Uses Managed Identity if available
var tokenCredential = new AzureTokenCredentials(credential);

 

var updateDatasourceRequest = new UpdateDatasourceRequest
{
    CredentialDetails = new CredentialDetails(
        new ManagedIdentityCredentials(resourceId, clientId), // Hypothetical class
        PrivacyLevel.None,
        EncryptedConnection.NotEncrypted
    )
};

 

Things to check

 

1. Is the Managed Identity assigned to the resource (like Azure SQL Database)?
2. Does the identity have the necessary permissions?
3. Is the SDK version up-to-date?

 

If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.

 

Thank you

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors