Creating the Data Source Name
This section describes how to edit the DSN configuration and then authenticate and connect to Amazon Redshift APIs.
DSN Configuration
You can use the Microsoft ODBC Data Source Administrator to edit the DSN configuration. Note that the installation process creates a both a user DSN and a system DSN, as described in Installing the Connector.
Note: The connector stores connection information in the Windows registry. To ensure that the connector can write to the registry, either run Power BI as an administrator or use a User DSN for your connection instead of a System DSN.
User DSN
Complete the following steps to edit the DSN configuration:
- Select Start > Search, and enter ODBC Data Sources in the Search box.
- Choose the version of the ODBC Administrator that corresponds to the bitness of your Power BI Desktop installation (32-bit or 64-bit).
- Select the system data source and click Configure.
- Edit the information on the Connection tab and click OK.
System DSN
Configure the system DSN the same way as the user DSN, except you will need to switch to the System DSN tab before performing Step 3.
Connecting to Amazon Redshift
The following connection properties are usually required to connect to Amazon Redshift.
- Server: The host name or IP of the server hosting the Amazon Redshift database.
- Database: The database that you created for your Amazon Redshift cluster.
- Port (optional): The port of the server hosting the Amazon Redshift database. 5439 by default.
Follow these steps to obtain these values in the AWS Management Console:
- Open the Amazon Redshift console (http://console.aws.amazon.com/redshift).
- On the Clusters page, click the name of the cluster.
- On the Configuration tab, obtain the properties from the "Cluster Database Properties" section. The connection property values are the same as the values set in the ODBC URL.
The connector provides secure communication with Amazon Redshift server using SSL encryption. You can optionally turn off SSL encryption by setting UseSSL to false.
You can also leverage SSL authentication to connect to Amazon Redshift data. To do so, specify the following connection properties:
- SSLClientCert: Set this to the name of the certificate store for the client certificate. This is used in the case of 2-way SSL, where truststore and keystore are kept on both the client and server machines.
- SSLClientCertPassword: If a client certificate store is password-protected, set this value to the store's password.
- SSLClientCertSubject: The subject of the TLS/SSL client certificate. This is used to locate the certificate in the store.
- SSLClientCertType: The certificate type of the client store.
- SSLServerCert: The certificate to be accepted from the server.
The following is the example connection string to connect Amazon Redshift using a standard user and password pair and inactive SSL encryption:
User=username;Password=password;Server=example.us-west-2.redshift.amazonaws.com;Database=your_database;UseSSL=false;"
Authenticating to Amazon Redshift
Azure Active Directory
Prerequisites
- Only non-B2C Azure tenants can complete the Azure AD authentication scheme.
- You must have an active Azure AD account. If you do not have an active account, create one before beginning this process.
Authentication
To authenticate to Azure AD, you must complete these tasks:- Create and Register an OAuth Application
- Create and Configure a Redshift Client Application
- Define a New Identity Provider
- Specify Connection Properties
The following sections describe these tasks in detail.
Create and Register an OAuth Application
Follow these steps to create an OAuth app for logging into your Amazon Redshift database via Azure:
- On the Azure Active Directory Overview page, in the left navigation bar, select App registrations.
- Click New registrations at the top of the App registrations page.
- On the Register an app page, fill in your details and click Register at the bottom of the page. Save your CallbackURL property value.
- After the creation of the application, you are brought to its Overview page. From there, in the left navigation bar:
- Click Certificates & secrets.
- Click New client secret.
- In the Add a client secret window, supply your details and click Add at the bottom of the window.
- Save your OAuthClientSecret (the Value field of the OAuth secret that is displayed).
- From the newly registered application, click Expose an API in the left navigation bar.
- Next to the App ID URI, click Set.
- The Set the App ID URI dialog appears with the information filled in from registering. Click Save.
- Click Add a scope.
- Fill in your details and click Add scope at the bottom of the form.
Create and Configure a Redshift Client Application
Follow these steps to create another application, which serves as the client application for your Amazon Redshift database:
- Navigate to the Azure Active Directory management page and click App registrations.
- Click New registrations at the top of the page.
- On the Register an application page, fill in your details and click Register at the bottom of the page.
- Following the creation of the app, you are sent to its Overview page. From there, in the left navigation bar:
- Click Certificates & secrets.
- Click New client secret.
- In the Add a client secret window, supply your details and click Add at the bottom of the window.
- Save your OAuthClientSecret (the Value field of the OAuth secret that is displayed).
- In the left navigation bar of the client app's management page:
- Click API permissions.
- Click Add a permission.
- Choose Microsoft Graph API.
- Click Application permissions.
- Select Directory > "Directory.Read.All".
- Click Add at the bottom.
- Click Grant admin consent.
- Click Yes.
- In the Azure Active Directory left navigation bar:
- Click Groups.
- On the Groups page, click New group and fill in the details.
- Click No owners selected.
- The Add owners window appears. Select the user.
- Click Create.
Define a New Identity Provider
Follow these steps to define a new Identify Provider:
- In the Azure Active Directory Overviewpage:
- Select App registrations from the left navigation pane.
- Select the All applications tab and choose your first OAuth application.
- In the left navigation bar on the OAuth page, click Manifest. Search in the editor for the accessTokenAcceptedVersion. If the value is null, it is a v1.0 token. If the value is set to 2, this is a v2.0 token.
- From the Amazon Redshift instance's query box, submit the identity provider query, following the example below:
CREATE IDENTITY PROVIDER oauth_standard TYPE azure NAMESPACE 'mynamespace' PARAMETERS '{ "issuer":"https://sts.windows.net/your_tenant_here/", "client_id":"YourClientId", "client_secret":"YourClientSecret", "audience":["your_application_id_uri_here"] }'
Terminology Guide:
- Your issuer ID: The issuer ID to trust when a token is received. The unique identifier for the tenant_id is appended to the issuer. If using a v1.0 token, use https://sts.windows.net/<your_tenant_id_here>/. If using a v2.0 token, use https://login.microsoftonline.com/<your_tenant_id_here>/v2.0.
- Your client_id: The unique, public identifier of the application registered with the identity provider. This is referred to as the application ID. It is the clien ID generated for the second application (the Amazon Redshift client application).
- Your client_secret: A secret identifier, or password, known only to the identity provider and the registered application. This is the secret generated for the second application (the Amazon Redshift application).
- audience: The Application ID (URI) assigned to the first application (the OAuth application).
You can use any name you like for the NAMESPACE.
- In Amazon Redshift, place the CREATE IDENTITY PROVIDER query (like above example) into the query text box.
- Click Run at the bottom of the query box.
- In the query text box, create a role on the Redshift database in this format:
create role "mynamespace:myazuregroup";
Replace with your identity provider's namespace provided in the CREATE IDENTITY PROVIDER query and the name of Azure group that you created earlier. Click Run at the bottom of the query box. - In the query text box, grant table access to this new role as follows:
grant select on all tables in schema public to role "mynamespace:myazuregroup";
- Replace the above example with your namespace and Azure group name.
- Click Run at the bottom of the query box.
Set Connection Properties
Specify the following connection properties:
- AuthScheme: Set this to AzureAD.
- Server: Set this to the name of your Amazon Redshift server endpoint.
- Database: Set this to the name of your Amazon Redshift database that you would like to connect to.
- User: Set this to the name of the authenticating Amazon Redshift user.
- AzureTenant: Set this to the ID of the Azure Tenant that your OAuth and client apps were created under. Find this in the Overview page of one of the apps under Directory (tenant) ID.
- SSOLoginURL: Set this to the value of the Application ID URI, visible on the Overview page of your OAuth app.
- Scope: For v1.0 OAuth tokens, set this to the Scopes field in the Expose an API page of your OAuth app. For v2.0 OAuth tokens, this will be the same as the OAuth app's Client ID.
- OAuthClientID: Set this to the first OAuth application client ID in the Overview page of the Amazon Redshift client application that you created.
- OAuthClientSecret: For your first OAuth application, set this to the Value of the OAuth client secret from the client application's Certificates & secrets page.
- CallbackURL: Set this to the callback URL of the OAuth app.
Troubleshooting Note If you encounter an "Azure JWT token does not have 'upn' field" error, follow these steps:
- On the Azure Active Directory management page, navigate to App Registrations and select your OAuth application.
- Click Token configuration in the left navigation bar.
- Click Add optional claim.
- In the Add optional claim screen, under Token type, click Access.
- Under the Claim column, select upn.
- Click Add at the bottom.
- Select Turn on the Microsoft Graph profile permission (required for claims to appear in the token).
- Click Add.
- Repeat this process for the client app.
- Attempt the connection again.
Azure Active Directory PKCE
To authenticate via Azure AD PKCE, you must complete the following tasks:- Create and Register an OAuth Application
- Create and Configure a Redshift Client Application
- Define a New Identity Provider
- Specify Connection Properties
The following sections describe these tasks in detail.
Create and Register an OAuth Application
Follow these steps to create an OAuth application for logging into your Amazon Redshift database via Azure:
- On the Azure Active Directory Overview page, in the left navigation bar, Click App registrations.
- Click New registrations at the top of the App registrations page.
- On the Register an application page, fill in your details:
- For Name, enter a name (for example, "oauth_application").
- For Redirect URI, choose Public client/native (mobile and desktop) and enter a valid URL (for example, http://localhost:33333/).
- Click Register at the bottom of the page. Save the CallbackURL property value.
- From the newly registered application, click Expose an API in the left navigation bar.
- Next to the Application ID URI, click Set.
- The Set the App ID URI dialog appears with the information filled in your registration. Click Save.
- Click Add a scope.
- Fill in your details and click Add scope at the bottom of the form.
- Save the generated Application ID URI and the API scope; for example, api://6256f0b1-2284-43e4-8501-6e53dec4444f and api://6256f0b1-2284-43e4-8501-6e53dec4444f/jdbc_login.
Create and Configure a Redshift Client Application
Follow these steps to create another application, which serves as the client application for your Amazon Redshift database:
- On the Azure Active Directory Overview page, select App registrations from the left navigation bar.
- At the top of the App registrations page, click New registrations.
- On the Register an application page, fill in your details and click Register at the bottom of the page.
- After the creation of the application, you are brought to its Overview page. From there, in the left navigation bar:
- Click Certificates & secrets.
- Click New client secret.
- In the Add a client secret window, add your details and click Add at the bottom of the window.
- Save your OAuthClientSecret (the Value field of the OAuth secret that is displayed).
- In the left navigation bar of the client app's management page:
- Click API permissions.
- Click Add a permission.
- Choose Microsoft Graph API.
- Click Application permissions.
- Select Directory > "Directory.Read.All".
- Click Add at the bottom.
- Click Grant admin consent
- Click Yes.
- In the Azure Active Directory left navigation bar:
- Click Groups.
- On the Groups page, click New group and fill in the details.
- Click No owners selected.
- The Add owners window appears. Select the user.
- Click Create.
Define a New Identity Provider
Follow these steps to define a new Identity Provider:
- In the Azure Active Directory left navigation bar, click App registrations.
- Select the All applications tab and choose your first OAuth application.
- On the OAuth screen, in the left navigation bar, click Manifest. Look in the editor for the accessTokenAcceptedVersion. If the value is null or 1, it is a v1.0 token. If the value is 2, this is a v2.0 token.
- From the Amazon Redshift instance's query box, submit the identity provider query, following the example below:
CREATE IDENTITY PROVIDER oauth_standard TYPE azure NAMESPACE 'mynamespace' PARAMETERS '{ "issuer":"https://sts.windows.net/your_tenant_here/", "client_id":"YourRedshiftApplicationClientId", "client_secret":"YourRedshiftApplicationClientSecret" ,"audience":["your_oauth_application_id_uri_here"] }'
For a v2.0 token issuer the value should be:"issuer":"https://login.microsoftonline.com/your_tenant_here/v2.0",
- Terminology Guide:
- Your issuer ID: The issuer ID to trust when a token is received. The unique identifier for the tenant_id is appended to the issuer. If you are using a v1.0 token, specify https://sts.windows.net<your_tenant_id_here>. If you are using a v2.0 token, specify https://login.microsoftonline.com<your_tenant_id_here>/v2.0..
- Your client_id: The unique, public identifier of the application registered with the identity provider. This is referred to as the application ID. It is the client ID generated for the second application (the Amazon Redshift application).
- Your client_secret: A secret identifier, or password, known only to the identity provider and the registered application. This is the secret generated for the second application (the Amazon Redshift application).
- audience: The Application ID (URI) assigned to the first application (the OAuth application).
- You can use any name you like for the namespace.
- In Amazon Redshift, place the CREATE IDENTITY PROVIDER query (like the above example) into the query text box.
- Click Run at the bottom of the query box.
- In the query text box, create a role on the Redshift database in this format:
create role "mynamespace:myazuregroup";
- Replace with your identity provider's namespace provided in the CREATE IDENTITY PROVIDER query and the name of the Azure group you created earlier.
- Click Run at the bottom of the query box.
- In the query text box, grant table access to this new role as follows:
grant select on all tables in schema public to role "mynamespace:myazuregroup";
- Replace the above example with your namespace and Azure group name.
- Click Run at the bottom of the query box.
Set Connection Properties
After finishing the above configuration, specify the following properties in the driver to connect to amazon Redshift:
- AuthScheme: Set this to AzureADPKCE.
- Server: Set this to the name of your Amazon Redshift server endpoint.
- Database: Set this to the name of your Amazon Redshift database that you want to connect to.
- Scope: For v1.0 OAuth tokens, set this to the Scopes field in the Expose an API page of your OAuth application (for example,api://d3cb3521-6c20-4e41-b16d-e48c8444ee11/jdbc_login). For v2.0 OAuth tokens, this is the same as the OAuth app's Client ID (for example, d3cb3521-6c20-4e41-b16d-e48c8444ee11).
- OAuthClientID: Set this to the Application (client) ID in the Overview page of the OAuth application you created.6.
- CallbackURL: Set this to the callback URL of the OAuth app.
Troubleshooting Note
If you encounter an "Azure JWT token does not have 'upn' field" error, follow these steps:
- On the Azure Active Directory management page, navigate to App Registrations and select your OAuth application.
- Select Token configuration > Add Optional claim in the left navigation bar.
- In the Add optional claim screen, under "Token type", click Access.
- Under the Claim column, select upn.
- Click Add at the bottom.
- Select Turn on the Microsoft Graph profile permission, which is required for claims to appear in the token.
- Click Add.
- Repeat this process for the client app.
- Attempt the connection again.
Standard Authentication
Set the AuthScheme to Basic to connect to Amazon Redshift with login credentials. In addition, set the following connection properties:
- User: The user which will be used to authenticate with the Amazon Redshift server.
- Password: The password which will be used to authenticate with the Amazon Redshift server.
AuthScheme=Basic;User=user;Password=password;Server=example.us-west-2.redshift.amazonaws.com;Database=your_database;
IAM credentials
Set the AuthScheme to IAMCredentials. The following is an example connection string:
AuthScheme=IAMCredentials;Server=example.us-west-2.redshift.amazonaws.com;Database=your_database;User=your_user;AWSAccessKey=your_access_key;AWSSecretKey=your_secretkey;
If you are connecting IAM role with temporary credentials you are also required to apply AWSSessionToken.
You can optionally apply:
- AutoCreate: Create a database user with the name specified for User if one does not exist while connecting.
- DbGroups: Database groups the database user joins for the current session.
ADFS
To connect to ADFS, set the AuthScheme to ADFS, and set these properties:
- User: The ADFS user.
- Password: The ADFS user's password.
- SSOLoginURL: The SSO provider's login url.
Example connection string:
AuthScheme=ADFS;User=username;Password=password;SSOLoginURL='https://sts.company.com';
ADFS Integrated
The ADFS Integrated flow indicates you are connecting with the currently logged in Windows user credentials. To use the ADFS Integrated flow, do not specify the User and Password, but otherwise follow the same steps in the ADFS guide above.
To connect to PingFederate, set AuthScheme to PingFederate, and set these properties:
- User: The PingFederate user.
- Password: The PingFederate user's password.
- SSOLoginURL: The SSO provider's login url.
- AWSRoleARN (optional): If you have multiple role ARNs, specify the one you want to use for authorization.
- AWSPrincipalARN (optional): If you have multiple principal ARNs, specify the one you want to use for authorization.
- SSOProperties (optional): Authscheme=Basic if you want to include your username and password as an authorization header in requests to Amazon S3.
To enable mutual SSL authentication for SSOLoginURL, the WS-Trust STS endpoint, configure these SSOProperties:
- SSLClientCert
- SSLClientCertType
- SSLClientCertSubject
- SSLClientCertPassword
Example connection string:
Server=redshift-cluster-1.xxxxxxxxxxxx.us-east-1.redshift.amazonaws.com;Database=dev;Port=5439;UseSSL=true;SSLServerCert=*;AuthScheme=PingFederate;AutoCreate=TRUE;SSOLoginURL=https://mycustomserver.com:9033/idp/sts.wst;SSOExchangeUrl=https://us-east-1.signin.aws.amazon.com/platform/saml/acs/764ef411-xxxxxx;User=admin;Password=PassValue;AWSRegion=NORTHERNVIRGINIA;