You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -50,6 +50,37 @@ Follow these steps to create an Azure Automation Account through the method of s
50
50
1. Select **Review+Create**.
51
51
1. Finish creation of the automation account by selecting **Create**.
52
52
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
+
53
84
> [!TIP]
54
85
> 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.
0 commit comments