Skip to content

Commit 8faaa7a

Browse files
authored
Merge pull request #114556 from mamccrea/sql-synapse-preview
sql msi and synapse output
2 parents fd30125 + 93942f4 commit 8faaa7a

11 files changed

+153
-8
lines changed

articles/stream-analytics/TOC.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
items:
5959
- name: Outputs overview
6060
href: stream-analytics-define-outputs.md
61+
displayName: adls, sql, blob, event hubs, power bi, table, service bus, cosmos, functions
6162
- name: Output to Cosmos DB
6263
href: stream-analytics-documentdb-output.md
6364
- name: Output to Azure SQL DB
@@ -127,14 +128,22 @@
127128
href: copy-job.md
128129
- name: Pair jobs for reliability
129130
href: stream-analytics-job-reliability.md
130-
- name: Authenticate with managed identity - ADLS Gen 1 output
131-
href: stream-analytics-managed-identities-adls.md
132131
- name: Use SQL reference data
133132
href: sql-reference-data.md
134-
- name: Authenticate with managed identity - Blob output
135-
href: blob-output-managed-identity.md
136-
- name: Authenticate with managed identity - Power BI
137-
href: powerbi-output-managed-identity.md
133+
- name: Authenticate with managed identity
134+
items:
135+
- name: ADLS Gen 1
136+
href: stream-analytics-managed-identities-adls.md
137+
displayName: managed identity, identities, authenticate
138+
- name: Blob storage
139+
href: blob-output-managed-identity.md
140+
displayName: managed identity, identities, authenticate
141+
- name: Power BI
142+
href: powerbi-output-managed-identity.md
143+
displayName: managed identity, identities, authenticate
144+
- name: Azure SQL DB
145+
href: sql-database-output-managed-identity.md
146+
displayName: managed identity, identities, authenticate
138147
- name: Encrypt your data
139148
href: data-protection.md
140149
- name: Build solutions

articles/stream-analytics/configuration-error-codes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.service: stream-analytics
1212

1313
You can use activity logs and resource logs to help debug unexpected behaviors from your Azure Stream Analytics job. This article lists the description for every configuration error code. Configuration errors are related to your job configuration, or input and output configurations.
1414

15-
## Error code: KafkaInvalidPermission
15+
## KafkaInvalidPermission
1616

1717
* **Cause**: The Stream Analytics job doesn't have the proper permission to perform certain actions.
1818

65.6 KB
Loading
23.6 KB
Loading
89 KB
Loading
85.8 KB
Loading
52.8 KB
Loading
159 KB
Loading
56.5 KB
Loading
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
title: Use managed identities to access Azure SQL Database - Azure Stream Analytics
3+
description: This article describes how to use managed identities to authenticate your Azure Stream Analytics job to Azure SQL DB output.
4+
author: mamccrea
5+
ms.author: mamccrea
6+
ms.service: stream-analytics
7+
ms.topic: conceptual
8+
ms.date: 05/08/2020
9+
---
10+
11+
# Use managed identities to access Azure SQL Database from an Azure Stream Analytics job (Preview)
12+
13+
Azure Stream Analytics supports [Managed Identity authentication](../active-directory/managed-identities-azure-resources/overview.md) for Azure SQL Database output sinks. Managed identities eliminate the limitations of user-based authentication methods, like the need to reauthenticate due to password changes or user token expirations that occur every 90 days. When you remove the need to manually authenticate, your Stream Analytics deployments can be fully automated.
14+
15+
A managed identity is a managed application registered in Azure Active Directory that represents a given Stream Analytics job. The managed application is used to authenticate to a targeted resource. This article shows you how to enable Managed Identity for an Azure SQL Database output(s) of a Stream Analytics job through the Azure portal.
16+
17+
## Prerequisites
18+
19+
The following are required to this feature:
20+
21+
- An Azure Stream Analytics job.
22+
23+
- An Azure SQL Database resource.
24+
25+
## Create a managed identity
26+
27+
First, you create a managed identity for your Azure Stream Analytics job.
28+
29+
1. In the [Azure portal](https://portal.azure.com), open your Azure Stream Analytics job.
30+
31+
1. From the left navigation menu, select **Managed Identity** located under **Configure**. Then, check the box next to **Use System-assigned Managed Identity** and select **Save**.
32+
33+
![Select system-assigned managed identity](./media/sql-db-output-managed-identity/system-assigned-managed-identity.png)
34+
35+
36+
A service principal for the Stream Analytics job's identity is created in Azure Active Directory. The life cycle of the newly created identity is managed by Azure. When the Stream Analytics job is deleted, the associated identity (that is, the service principal) is automatically deleted by Azure.
37+
38+
1. When you save the configuration, the Object ID (OID) of the service principal is listed as the Principal ID as shown below:
39+
40+
![Object ID shown as Principal ID](./media/sql-db-output-managed-identity/principal-id.png)
41+
42+
The service principal has the same name as the Stream Analytics job. For example, if the name of your job is *MyASAJob*, the name of the service principal is also *MyASAJob*.
43+
44+
## Select an Active Directory admin
45+
46+
After you've created a managed identity, you select an Active Directory admin.
47+
48+
1. Navigate to your Azure SQL Database resource and select the SQL Server that the database is under. You can find the SQL Server name next to *Server name* on the resource overview page.
49+
50+
1. Select **Active Directory Admin** under **Settings**. Then, select **Set admin**.
51+
52+
![Active Directory admin page](./media/sql-db-output-managed-identity/active-directory-admin-page.png)
53+
54+
1. On the Active Directory admin page, search for a user or group to be an administrator for the SQL Server and click **Select**.
55+
56+
![Add Active Directory admin](./media/sql-db-output-managed-identity/add-admin.png)
57+
58+
1. Select **Save** on the **Active Directory admin** page. The process for changing admin takes a few minutes.
59+
60+
## Create a database user
61+
62+
Next, you create a contained database user in your SQL Database that is mapped to the Azure Active Directory identity. The contained database user doesn't have a login for the master database, but it maps to an identity in the directory that is associated with the database. The Azure Active Directory identity can be an individual user account or a group. In this case, you want to create a contained database user for your Stream Analytics job.
63+
64+
1. Connect to the SQL database using SQL Server Management Studio. The **User name** is an Azure Active Directory user with the **ALTER ANY USER** permission. The admin you set on the SQL Server is an example. Use **Azure Active Directory – Universal with MFA** authentication.
65+
66+
![Connect to SQL Server](./media/sql-db-output-managed-identity/connect-sql-server.png)
67+
68+
The server name `<SQL Server name>.database.windows.net` may be different in different regions. For example, the China region should use `<SQL Server name>.database.chinacloudapi.cn`.
69+
70+
You can specify a specific SQL Database by going to **Options > Connection Properties > Connect to Database**.
71+
72+
![SQL Server connection properties](./media/sql-db-output-managed-identity/sql-server-connection-properties.png)
73+
74+
1. When you connect for the first time, you may encounter the following window:
75+
76+
![New firewall rule window](./media/sql-db-output-managed-identity/new-firewall-rule.png)
77+
78+
1. If so, go to your SQL Server resource on the Azure portal. Under the **Security** section, open the **Firewalls and virtual network** page.
79+
1. Add a new rule with any rule name.
80+
1. Use the *From* IP address from the **New Firewall Rule** window for the *Start IP*.
81+
1. Use the *To* IP address from the **New Firewall Rule** window for *End IP*.
82+
1. Select **Save** and attempt to connect from SQL Server Management Studio again.
83+
84+
1. Once you are connected, create the contained database user. The following SQL command creates a contained database user that has the same name as your Stream Analytics job. Be sure to include the brackets around the *ASA_JOB_NAME*. Use the following T-SQL syntax and run the query.
85+
86+
```sql
87+
CREATE USER [ASA_JOB_NAME] FROM EXTERNAL PROVIDER;
88+
```
89+
90+
## Grant Stream Analytics job permissions
91+
92+
The Stream Analytics job has permission from Managed Identity to **CONNECT** to your SQL Database resource. Most likely, it would be efficient to allow the Stream Analytics job to run commands such as **SELECT**. You can grant those permissions to the Stream Analytics job using SQL Server Management Studio. For more information, see the [GRANT (Transact-SQL)](https://docs.microsoft.com/sql/t-sql/statements/grant-transact-sql?view=sql-server-ver15) reference.
93+
94+
Alternatively, you can right-click on your SQL database in SQL Server Management Studio and select **Properties > Permissions**. From the permissions menu, you can see the Stream Analytics job you added previously, and you can manually grant or deny permissions as you see fit.
95+
96+
## Create an Azure SQL Database output
97+
98+
Now that your managed identity is configured, you're ready to add the Azure SQL Database as output to your Stream Analytics job.
99+
100+
1. Go back to your Stream Analytics job, and navigate to the **Outputs** page under **Job Topology**.
101+
102+
1. Select **Add > SQL Database**. In the output properties window of the SQL Database output sink, select **Managed Identity** from the Authentication mode drop-down.
103+
104+
1. Fill out the rest of the properties. To learn more about creating an SQL Database output, see [Create a SQL Database output with Stream Analytics](stream-analytics-define-outputs.md#sql-database). When you are finished, select **Save**.
105+
106+
## Next steps
107+
108+
* [Understand outputs from Azure Stream Analytics](stream-analytics-define-outputs.md)
109+
* [Azure Stream Analytics output to Azure SQL Database](stream-analytics-sql-output-perf.md)

0 commit comments

Comments
 (0)