Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
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
Solved! Go to Solution.
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
Managed identities for Azure resources - Managed identities for Azure resources | Microsoft Learn
Managed identities for Azure - Azure Service Fabric | Microsoft Learn
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 ,
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
Managed identities for Azure resources - Managed identities for Azure resources | Microsoft Learn
Managed identities for Azure - Azure Service Fabric | Microsoft Learn
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
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
No there is no Hypothetical class ManagedIdentityCredentials. So I assume no
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
User | Count |
---|---|
13 | |
7 | |
2 | |
2 | |
2 |
User | Count |
---|---|
3 | |
3 | |
3 | |
2 | |
2 |