Skip to content

Commit 0cc64a7

Browse files
thesqlsithrwestMSFT
authored andcommitted
add role assigment step
Update automatic-tuning-email-notifications-configure.md Update automatic-tuning-email-notifications-configure.md Update automatic-tuning-email-notifications-configure.md
1 parent 65e9811 commit 0cc64a7

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

azure-sql/database/automatic-tuning-email-notifications-configure.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ titleSuffix: Azure SQL Database & Azure SQL Managed Instance
44
description: Enable e-mail notifications for Azure SQL Database automatic query tuning.
55
author: WilliamDAssafMSFT
66
ms.author: wiassaf
7-
ms.reviewer: nnikolic, mathoma, dwilson
8-
ms.date: 02/28/2025
7+
ms.reviewer: nnikolic, mathoma, derekw
8+
ms.date: 04/22/2025
99
ms.service: azure-sql
1010
ms.subservice: performance
1111
ms.topic: how-to
@@ -50,6 +50,37 @@ Follow these steps to create an Azure Automation Account through the method of s
5050
1. Select **Review+Create**.
5151
1. Finish creation of the automation account by selecting **Create**.
5252

53+
## Assign Azure roles to the system-assigned managed identity account
54+
55+
An Automation account can use its system-assigned managed identity to get tokens to access other resources protected by Microsoft Entra ID, such as Azure SQL Database. These tokens don't represent any specific user of the application. Instead, they represent the application that's accessing the resource. In this case, for example, the token represents an Automation account.
56+
57+
Before creating an Azure Automation runbook, it is important to grant the appropriate level of permissions to the automation account, following the principle of least privilege. When you use a system assigned managed identity, adding the **SQL DB Contributor** and **SQL Server Contributor** roles to the SAMI is sufficient for automating Azure SQL Database tasks. For most scenarios, if your automation only targets specific databases, use the resource group level scope. If it must operate across an entire subscription, use the subscription level scope.
58+
59+
The following example uses Azure PowerShell to assign the **SQL DB Contributor** role in the current subscription to the system assigned managed identity account.
60+
61+
```powershell
62+
$roleAssignmentParams = @{
63+
ObjectId = "<automation-Identity-object-id>"
64+
Scope = "/subscriptions/<subscription-id>"
65+
RoleDefinitionName = "SQL DB Contributor"
66+
}
67+
68+
New-AzRoleAssignment @roleAssignmentParams
69+
```
70+
71+
To add these roles to a system-assigned managed identity from within the Azure Portal, follow these steps:
72+
73+
1. Sign in to the Azure portal.
74+
1. Locate the newly created Azure Automation account.
75+
1. Under Account Settings, select **Identity**.
76+
1. Under Permissions, select the **Azure role assignments** box.
77+
1. Select **Add role assignment (Preview)**.
78+
1. In the Scope dropdown list, select the set of resources that the role assignment applies - Subscription, Resource group, Role, and Scope.
79+
1. In the Role dropdown list, select a role as **SQL DB Contributor**.
80+
1. Select **Save**.
81+
82+
Repeat the steps from the Add role assignment step in order to add the **SQL Server Contributor** role.
83+
5384
> [!TIP]
5485
> Record your Azure Automation account name, subscription ID, and resources (such as copy-paste to a notepad) exactly as entered while creating the Automation app. You need this information later.
5586

0 commit comments

Comments
 (0)