Skip to content

Commit 436c259

Browse files
author
Mark Dalton Gray
committed
grant permission to extension identity
1 parent 6fcb19c commit 436c259

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

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

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,83 @@ 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 baremetal machines within your Nexus Cluster, you must grant the nc-platform-extension identity of the cluster the ability 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, as such the following example must be performed after the cluster is deployed.
64+
65+
The required permission is ```Microsoft.Security/mdeOnboardings/read```. This permission can be assigned to the nc-platform-extension identity using the built-in role ```Security Reader``` or a custom role with the same permission can be created.
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+
70+
Below is an example bash script using the az CLI for granting the nc-platform-extension identity the ability to onboard the MDE agent on your behalf.
71+
72+
```bash
73+
#!/usr/bin/env bash
74+
75+
# Usage: ./script.sh /subscriptions/<subID>/resourceGroups/<rgName>/providers/Microsoft.NetworkCloud/clusters/<clusterName>
76+
77+
CLUSTER_ID="$1"
78+
79+
if [ -z "$CLUSTER_ID" ]; then
80+
echo "Usage: $0 <Full Azure Network Cloud Cluster Resource ID>"
81+
exit 1
82+
fi
83+
84+
# 1. Extract Subscription ID by splitting on '/' and taking the 3rd field:
85+
SUBSCRIPTION_ID=$(echo "$CLUSTER_ID" | cut -d'/' -f3)
86+
echo "Subscription ID: $SUBSCRIPTION_ID"
87+
88+
# 2. Extract the actual cluster name from the last segment in the resource ID
89+
CLUSTER_NAME=$(basename "$CLUSTER_ID")
90+
echo "Cluster name: $CLUSTER_NAME"
91+
92+
# 3. Retrieve the Managed Resource Group name
93+
MRG_NAME=$(az networkcloud cluster show \
94+
--ids "$CLUSTER_ID" \
95+
--query "managedResourceGroupConfiguration.name" \
96+
--output tsv)
97+
echo "Managed Resource Group name: $MRG_NAME"
98+
99+
# 4. Retrieve the extension's principal ID
100+
PRINCIPAL_ID=$(az k8s-extension show \
101+
--name nc-platform-extension \
102+
--cluster-name "$CLUSTER_NAME" \
103+
--resource-group "$MRG_NAME" \
104+
--cluster-type connectedClusters \
105+
--query "identity.principalId" \
106+
--output tsv)
107+
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+
133+
echo "Done. Security Reader role assignment created"
134+
135+
59136
### Operator Nexus-specific requirement for enabling Defender for Endpoint
60137

61138
> [!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)