Forum Discussion
Gateway Datasource with SPN credentials
- 3 years ago
Indeed, documentation is not clear : "The encryption algorithm. For a cloud data source, specify None. For an on-premises data source, specify RSA-OAEP and use the gateway public key to encrypt the credentials."
I think "on-premise" means "when you use data gateway". That's why I need to encrypt.
It finally works with this script :
$keyCreds = [Microsoft.PowerBI.Api.Models.Credentials.KeyCredentials]::new($patDatabricks) $gatewayKeyObj = [Microsoft.PowerBI.Api.Models.GatewayPublicKey]::new($gateway.publicKey.exponent, $gateway.publicKey.modulus) $credEncrypt = [Microsoft.PowerBI.Api.Extensions.AsymmetricKeyEncryptor]::new($gatewayKeyObj) $credentialDetails = [Microsoft.PowerBI.Api.Models.CredentialDetails]::new( $keyCreds, [Microsoft.PowerBI.Api.Models.PrivacyLevel]::Organizational, [Microsoft.PowerBI.Api.Models.EncryptedConnection]::Encrypted, $credEncrypt) $credentials = $credentialDetails.Credentials $body = @{ credentialDetails = @{ credentialType = "Key"; credentials = $encryptedCredentials; encryptedConnection = "Encrypted"; encryptionAlgorithm = "RSA-OAEP"; privacyLevel = "Organizational"; } } | ConvertTo-Json Invoke-PowerBIRestMethod -Url "gateways/$($gateway.id)/datasources/$($datasourceId)" -Method PATCH -Body $body
Hi , Koni
Thanks for the test and glad to hear that my previous posted method may help, for your current issue met in the PowerShell command, the error message "DMTS_InvalidEncryptionAlgorithmError" may indicates that the encryption algorithm specified in the PowerShell command is invalid. You can try changing the encryption algorithm to a valid one, such as "RSA-OAEP" or "RSA-OAEP-256". Here is an example of how to modify the PowerShell command to use "RSA-OAEP-256".
Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Indeed, documentation is not clear : "The encryption algorithm. For a cloud data source, specify None. For an on-premises data source, specify RSA-OAEP and use the gateway public key to encrypt the credentials."
I think "on-premise" means "when you use data gateway". That's why I need to encrypt.
It finally works with this script :
$keyCreds = [Microsoft.PowerBI.Api.Models.Credentials.KeyCredentials]::new($patDatabricks)
$gatewayKeyObj = [Microsoft.PowerBI.Api.Models.GatewayPublicKey]::new($gateway.publicKey.exponent, $gateway.publicKey.modulus)
$credEncrypt = [Microsoft.PowerBI.Api.Extensions.AsymmetricKeyEncryptor]::new($gatewayKeyObj)
$credentialDetails = [Microsoft.PowerBI.Api.Models.CredentialDetails]::new(
$keyCreds,
[Microsoft.PowerBI.Api.Models.PrivacyLevel]::Organizational,
[Microsoft.PowerBI.Api.Models.EncryptedConnection]::Encrypted,
$credEncrypt)
$credentials = $credentialDetails.Credentials
$body = @{
credentialDetails = @{
credentialType = "Key";
credentials = $encryptedCredentials;
encryptedConnection = "Encrypted";
encryptionAlgorithm = "RSA-OAEP";
privacyLevel = "Organizational";
}
} | ConvertTo-Json
Invoke-PowerBIRestMethod -Url "gateways/$($gateway.id)/datasources/$($datasourceId)" -Method PATCH -Body $body