|
| 1 | +--- |
| 2 | +title: "Azure Operator Nexus: Create Cluster Resource with a Managed Identity" |
| 3 | +description: Create Clusters using the User Assigned Managed Identity to access the Log Analytics Workspace. |
| 4 | +author: troy0820 |
| 5 | +ms.author: troyconnor |
| 6 | +ms.service: azure-operator-nexus |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 01/08/2025 |
| 9 | +ms.custom: template-how-to |
| 10 | +--- |
| 11 | + |
| 12 | + |
| 13 | +# Create a Cluster Resource with a Managed Identity |
| 14 | + |
| 15 | +To create a cluster without a service principal user name and password, you can now create a cluster with a user-assigned managed identity or a system-assigned managed identity that has permissions over the Log Analytics Workspace. This will be used when validating the hardware during hardware validation and when installing the extensions that utilize the Log Analytics Workspace. |
| 16 | + |
| 17 | +## Prerequisites |
| 18 | + |
| 19 | +* Install the latest version of the |
| 20 | + [appropriate CLI extensions](./howto-install-cli-extensions.md) |
| 21 | +* A Log Analytics Workspace |
| 22 | +* A user-assigned managed identity resource with permissions over the log analytics workspace of [Log Analytics Contributor](/azure/role-based-access-control/built-in-roles/analytics#log-analytics-contributor). |
| 23 | + |
| 24 | +> [!NOTE] |
| 25 | +> This functionality exists with the 2024-10-01-preview API and will be available with the 2025-02-01 GA API offered by Azure Operator Nexus |
| 26 | +
|
| 27 | + |
| 28 | +### Create and configure Log Analytics Workspace and User Assigned Managed Identity |
| 29 | + |
| 30 | +1. Create a Log Analytics Workspace [Create a Log Analytics Workspace](/azure/azure-monitor/logs/quick-create-workspace). |
| 31 | +1. Assign the "Log Analytics Contributor" role to users and managed identities which need access to the Log Analytics Workspace. |
| 32 | + 1. See [Assign an Azure role for access to the analytics Workspace](/azure/azure-monitor/logs/manage-access?tabs=portal#azure-rbac). The role must also be assigned to either a user-assigned managed identity or the cluster's own system-assigned managed identity. |
| 33 | + 1. For more information on managed identities, see [Managed identities for Azure resources](/entra/identity/managed-identities-azure-resources/overview). |
| 34 | + 1. If using the Cluster's system assigned identity, the system assigned identity needs to be added to the cluster before it can be granted access. |
| 35 | + 1. When assigning a role to the cluster's system-assigned identity, make sure you select the resource with the type "Cluster (Operator Nexus)." |
| 36 | + |
| 37 | +### Configure the cluster to use a user-assigned managed identity for Log Analytics Workspace access |
| 38 | + |
| 39 | +```azurecli-interactive |
| 40 | +az networkcloud cluster create --name "<cluster-name>" \ |
| 41 | + --resource-group "<cluster-resource-group>" \ |
| 42 | + --mi-user-assigned "<user-assigned-identity-resource-id>" \ |
| 43 | + --analytics-output-settings identity-type="UserAssignedIdentity" \ |
| 44 | + identity-resource-id="<user-assigned-identity-resource-id>" \ |
| 45 | + ... |
| 46 | + --subscription "<subscription>" |
| 47 | +``` |
| 48 | + |
| 49 | +### View the principal ID for the user-assigned managed identity |
| 50 | + |
| 51 | +The identity resource ID can be found by selecting "JSON view" on the identity resource; the ID is at the top of the panel that appears. The container URL can be found on the Settings -> Properties tab of the container resource. |
| 52 | + |
| 53 | +The CLI can also be used to view the identity and the associated principal ID data within the cluster. |
| 54 | + |
| 55 | +Example: |
| 56 | + |
| 57 | +```console |
| 58 | +az networkcloud cluster show --ids /subscriptions/<Subscription ID>/resourceGroups/<Cluster Resource Group Name>/providers/Microsoft.NetworkCloud/clusters/<Cluster Name> |
| 59 | +``` |
| 60 | + |
| 61 | +User-assigned identity example: |
| 62 | + |
| 63 | +```json |
| 64 | + "identity": { |
| 65 | + "type": "UserAssigned", |
| 66 | + "userAssignedIdentities": { |
| 67 | + "/subscriptions/<subscriptionID>/resourcegroups/<resourceGroupName>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/<userAssignedIdentityName>": { |
| 68 | + "clientId": "00001111-aaaa-2222-bbbb-3333cccc4444", |
| 69 | + "principalId": "bbbbbbbb-cccc-dddd-2222-333333333333" |
| 70 | + } |
| 71 | + } |
| 72 | + }, |
| 73 | +``` |
| 74 | + |
| 75 | +### Create and configure Log Analytics Workspace and System Assigned Managed Identity |
| 76 | + |
| 77 | +> [!NOTE] |
| 78 | +> The system-assigned managed identity that is created during cluster creation does not exist until the cluster is created. This system-assigned managed identity will need to have permissions over the scope of the Log Analytics Workspace with the role of Log Analytics Contributor before we can update the cluster to utilize this identity. This update must occur before the Cluster can be deployed. |
| 79 | +
|
| 80 | +```azurecli-interactive |
| 81 | +az networkcloud cluster update --name "<cluster-name>" \ |
| 82 | + --resource-group "<cluster-resource-group>" \ |
| 83 | + --mi-system-assigned "<system-assigned-identity-resource-id>" \ |
| 84 | + --analytics-output-settings identity-type="SystemAssignedIdentity" \ |
| 85 | + identity-resource-id="<user-assigned-identity-resource-id>" \ |
| 86 | + ... |
| 87 | + --subscription "<subscription>" |
| 88 | +``` |
| 89 | + |
| 90 | +### View the principal ID for the system-assigned managed identity |
| 91 | + |
| 92 | +The identity resource ID can be found by selecting "JSON view" on the identity resource; the ID is at the top of the panel that appears. The container URL can be found on the Settings -> Properties tab of the container resource. |
| 93 | + |
| 94 | +The CLI can also be used to view the identity and the associated principal ID data within the cluster. |
| 95 | + |
| 96 | +Example: |
| 97 | + |
| 98 | +```console |
| 99 | +az networkcloud cluster show --ids /subscriptions/<Subscription ID>/resourceGroups/<Cluster Resource Group Name>/providers/Microsoft.NetworkCloud/clusters/<Cluster Name> |
| 100 | +``` |
| 101 | + |
| 102 | +System-assigned identity example: |
| 103 | + |
| 104 | +```json |
| 105 | + "identity": { |
| 106 | + "principalId": "aaaaaaaa-bbbb-cccc-1111-222222222222", |
| 107 | + "tenantId": "aaaabbbb-0000-cccc-1111-dddd2222eeee", |
| 108 | + "type": "SystemAssigned" |
| 109 | + }, |
| 110 | +``` |
| 111 | + |
| 112 | + |
0 commit comments