Skip to content

Commit 000fda6

Browse files
authored
Merge pull request #295342 from Hacks4Snacks/graymark/extensionidentitysteps
[operator-nexus] Grant permission to extension identity
2 parents 15b1811 + 2eebea4 commit 000fda6

File tree

2 files changed

+87
-1
lines changed

2 files changed

+87
-1
lines changed

articles/operator-nexus/howto-set-up-defender-for-cloud-security.md

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ To aid your understanding of Defender for Cloud and its many security features,
2222
To successfully complete the actions in this guide:
2323
- You must have an Azure Operator Nexus subscription.
2424
- You must have a deployed Azure Arc-connected Operator Nexus instance running in your on-premises environment.
25-
- You must use an Azure portal user account in your subscription with Owner, Contributor or Reader role.
25+
- You must use an Azure portal user account in your subscription with Owner, Contributor, or Reader role.
2626

2727
## Enable Defender for Cloud
2828

@@ -56,6 +56,91 @@ To set up a Defender for Servers plan:
5656
:::image type="content" source="media/security/nexus-defender-for-servers-plan-settings.png" alt-text="Screenshot of Defender for Servers plan settings for Operator Nexus." lightbox="media/security/nexus-defender-for-servers-plan-settings.png":::
5757
* Click Continue to save any changed settings.
5858

59+
### Grant MDE Onboarding Permissions
60+
61+
To enable the Microsoft Defender for Endpoint (MDE) agent on bare metal machines within your Nexus Cluster, you must grant the nc-platform-extension identity of the cluster permission to onboard the MDE agent on your behalf.
62+
63+
The nc-platform-extension identity does not exist prior to deploying the Operator Nexus cluster. The following example must be performed after the Cluster is deployed.
64+
65+
The required permission is ```Microsoft.Security/mdeOnboardings/read```. Assign this permission to the nc-platform-extension identity using the built-in role ```Security Reader``` or a custom role with the same permission.
66+
67+
> [!IMPORTANT]
68+
> The user or identity creating the role assignment must have the ```Microsoft.Authorization/roleAssignments/write``` permission at the subscription level.
69+
> Executing the commands to show the principal ID object ID requires the Microsoft Entra role assignment of Directory Reader or equivalent.
70+
71+
Below is an example bash script using the Azure CLI for granting the nc-platform-extension identity permission to onboard the MDE agent on your behalf.
72+
73+
```bash
74+
#!/usr/bin/env bash
75+
76+
# Usage: ./script.sh /subscriptions/<subID>/resourceGroups/<rgName>/providers/Microsoft.NetworkCloud/clusters/<clusterName>
77+
78+
CLUSTER_ID="$1"
79+
80+
if [ -z "$CLUSTER_ID" ]; then
81+
echo "Usage: $0 <Full Azure Network Cloud Cluster Resource ID>"
82+
exit 1
83+
fi
84+
85+
# 1. Extract Subscription ID by splitting on '/' and taking the 3rd field:
86+
SUBSCRIPTION_ID=$(echo "$CLUSTER_ID" | cut -d'/' -f3)
87+
echo "Subscription ID: $SUBSCRIPTION_ID"
88+
89+
# 2. Extract the actual cluster name from the last segment in the resource ID
90+
CLUSTER_NAME=$(basename "$CLUSTER_ID")
91+
echo "Cluster name: $CLUSTER_NAME"
92+
93+
# 3. Retrieve the Managed Resource Group name
94+
MRG_NAME=$(az networkcloud cluster show \
95+
--ids "$CLUSTER_ID" \
96+
--query "managedResourceGroupConfiguration.name" \
97+
--output tsv)
98+
echo "Managed Resource Group name: $MRG_NAME"
99+
100+
# 4. Retrieve the extension's principal ID
101+
PRINCIPAL_ID=$(az k8s-extension show \
102+
--name nc-platform-extension \
103+
--cluster-name "$CLUSTER_NAME" \
104+
--resource-group "$MRG_NAME" \
105+
--cluster-type connectedClusters \
106+
--query "identity.principalId" \
107+
--output tsv)
108+
echo "Extension Principal ID: $PRINCIPAL_ID"
109+
110+
# 5. Show the full service principal object
111+
echo "Showing service principal details"
112+
az ad sp show --id "$PRINCIPAL_ID"
113+
114+
# 6. Show just the object ID
115+
OBJECT_ID=$(az ad sp show --id "$PRINCIPAL_ID" --query "id" --output tsv)
116+
echo "Service Principal Object ID: $OBJECT_ID"
117+
118+
# 7. Show additional properties (ObjectID, AppID, DisplayName) in a table
119+
echo "Service principal summary:"
120+
az ad sp show \
121+
--id "$PRINCIPAL_ID" \
122+
--query "{ObjectID:id, AppID:appId, DisplayName:displayName}" \
123+
--output table
124+
125+
# 8. Create a Security Reader role assignment at subscription level
126+
echo "Creating Security Reader role assignment at subscription level"
127+
az role assignment create \
128+
--role "Security Reader" \
129+
--subscription "$SUBSCRIPTION_ID" \
130+
--assignee-object-id "$OBJECT_ID" \
131+
--assignee-principal-type ServicePrincipal \
132+
--scope "/subscriptions/$SUBSCRIPTION_ID"
133+
134+
echo "Done. Security Reader role assignment created"
135+
```
136+
137+
While the required permissions are not assigned, the MDE onboarding reconciliation logic will continue to attempt to onboard the MDE agent until the permissions are granted. After permission assignment is complete, the MDE onboarding reconciliation will complete successfully with no additional action required.
138+
139+
Reconciliation of the MDE onboarding status is an exponential backoff process. The first retry attempt will be made after 10 minutes, the second after 20 minutes, and the third after 40 minutes. If three failures occur, the reconciliation will wait 10 minutes before attempting to onboard the MDE agent again (which will restart the exponential backoff process).
140+
141+
> [!IMPORTANT]
142+
> MDE Agent reconciliation runs independently on each of the bare metal machines in the cluster. As such the exact time it takes to onboard the MDE agent on all bare metal machines in the cluster will vary depending on the number of bare metal machines in the cluster and the initial time of the first onboarding attempt.
143+
59144
### Operator Nexus-specific requirement for enabling Defender for Endpoint
60145

61146
> [!IMPORTANT]

articles/operator-nexus/howto-use-mde-runtime-protection.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This document provides the steps to execute those tasks.
2222
## Before you begin
2323

2424
- Install the latest version of the [appropriate CLI extensions](./howto-install-cli-extensions.md).
25+
- Onboarding permissions granted to the nc-platform-extension identity of the cluster. See [Grant MDE Onboarding Permissions](./howto-set-up-defender-for-cloud-security.md).
2526

2627
## Setting variables
2728

0 commit comments

Comments
 (0)