Skip to content

Commit 4e687a5

Browse files
committed
Add system assigned MI for Linux
1 parent 708a228 commit 4e687a5

1 file changed

Lines changed: 95 additions & 19 deletions

File tree

articles/storage/files/files-managed-identities.md

Lines changed: 95 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ Benefits include:
4141

4242
Azure provides two types of managed identities: **system assigned** and **user assigned**.
4343

44-
A system assigned managed identity is restricted to one per resource and is tied to the lifecycle of this resource. You can grant permissions to the managed identity by using Azure role-based access control (Azure RBAC). The managed identity is authenticated with Microsoft Entra ID, so you don’t have to store any credentials in code. System assigned managed identities aren't supported on Linux VMs.
44+
A system assigned managed identity is restricted to one per resource and is tied to the lifecycle of this resource. You can grant permissions to the managed identity by using Azure role-based access control (Azure RBAC). The managed identity is authenticated with Microsoft Entra ID, so you don’t have to store any credentials in code.
4545

4646
User assigned managed identities enable Azure resources to authenticate to cloud services without storing credentials in code. You create this type of managed identity as a standalone Azure resource with its own lifecycle. A single resource, like a VM, can use multiple user assigned managed identities. Also, multiple VMs can share a single user assigned managed identity.
4747

48-
You can configure both user assigned and system assigned managed identities on Windows VMs.
48+
Although you can configure both user assigned and system assigned managed identities on a single VM, we recommend using one or the other.
4949

5050
## Prerequisites
5151

52-
This article assumes that you have an Azure subscription with permissions to create storage accounts and assign Azure RBAC roles. To assign roles, you need role assignments write permission (Microsoft.Authorization/roleAssignments/write) at the scope you want to assign the role.
52+
This article assumes that you have an Azure subscription with permissions to create storage accounts and assign Azure RBAC roles. To assign roles, you need role assignments write permission (`Microsoft.Authorization/roleAssignments/write`) at the scope you want to assign the role.
5353

5454
The clients that need to authenticate by using a managed identity shouldn't be joined to any domain.
5555

@@ -155,7 +155,7 @@ The enablement steps described here are for Azure VMs. If you want to enable a m
155155

156156
### Enable managed identity on an Azure VM
157157

158-
Follow these steps to enable a managed identity on an Azure VM.
158+
Follow these steps to enable a managed identity on a Windows VM running in Azure.
159159

160160
1. Sign in to the Azure portal and create a Windows VM. Your VM must run Windows Server 2019 or higher for server versions, or any Windows client version. See [Create a Windows virtual machine in the Azure portal](/azure/virtual-machines/windows/quick-create-portal).
161161

@@ -188,14 +188,25 @@ Follow these steps to assign the built-in Azure RBAC role [Storage File Data SMB
188188

189189
### [Linux](#tab/linux)
190190

191-
To configure a managed identity on a Linux VM running in Azure, follow these steps. Your VM must be running Azure Linux 3.0, Ubuntu 22.04, or Ubuntu 24.04.
191+
To configure a managed identity on a Linux VM running in Azure, follow these steps. Your VM must be running Azure Linux 3.0, Ubuntu 22.04, Ubuntu 24.04, RHEL 9.6+, or SLES 15 SP6+.
192192

193-
> [!NOTE]
194-
> System assigned managed identities aren't supported on Linux VMs. You must create a user assigned managed identity.
193+
### Enable managed identity on an Azure VM
194+
195+
The managed identity can be either [system assigned or user assigned](/entra/identity/managed-identities-azure-resources/overview#differences-between-system-assigned-and-user-assigned-managed-identities). If the VM has both system assigned and user assigned identities, Azure defaults to system assigned. Assign only one for best results.
196+
197+
#### Enable a system assigned managed identity
198+
199+
1. Sign in to the Azure portal.
200+
201+
1. You can enable a system assigned managed identity during VM creation on the **Management** tab. See [Create a Linux virtual machine in the Azure portal](/azure/virtual-machines/linux/quick-create-portal).
202+
203+
#### Enable a user assigned managed identity
195204

196-
1. Sign in to the Azure portal and [create a user assigned managed identity](/entra/identity/managed-identities-azure-resources/manage-user-assigned-managed-identities-azure-portal#create-a-user-assigned-managed-identity).
205+
1. Sign in to the Azure portal and follow the steps in [create a user assigned managed identity](/entra/identity/managed-identities-azure-resources/manage-user-assigned-managed-identities-azure-portal#create-a-user-assigned-managed-identity).
197206

198-
1. Go to the managed identity you just created and copy the **Client ID**. You need this value later.
207+
1. Go to the user assigned managed identity you just created and copy the **Client ID**. You need this value later.
208+
209+
### Assign a built-in RBAC role to the managed identity
199210

200211
1. Go to the storage account that contains the file share you want to mount by using a managed identity. Select **Access Control (IAM)** from the service menu.
201212

@@ -207,15 +218,19 @@ To configure a managed identity on a Linux VM running in Azure, follow these ste
207218

208219
1. Under **Members**, select **+ Select members**. The **Select managed identities** pane appears.
209220

210-
1. Under **Managed identity**, select the user assigned managed identity that you created, and then click **Select**.
221+
1. Under **Managed identity**, select the managed identity, and then click **Select**.
211222

212223
1. You should now see the managed identity listed under **Members**. Select **Next**.
213224

214225
1. Select **Review + assign** to add the role assignment to the storage account.
215226

227+
### Add user assigned managed identity to VM
228+
229+
If you created a user assigned managed identity, follow these steps.
230+
216231
1. Go to your VM. From the service menu, under **Security**, select **Identity**.
217232

218-
1. Select the **User assigned** tab, and then select **Add user assigned managed identity**. Select the user assigned managed identity you created, and then select **Add**.
233+
1. Select the **User assigned** tab, and then select **Add user assigned managed identity**. Select the managed identity you created, and then select **Add**.
219234

220235
---
221236

@@ -284,6 +299,50 @@ tdnf update
284299
tdnf install azfilesauth
285300
```
286301

302+
#### RHEL 9.6+
303+
304+
Run the following commands to install `azfilesauth` on RHEL 9.6+:
305+
306+
```bash
307+
curl -sSL -O https://packages.microsoft.com/config/$(source /etc/os-release && echo "$ID/${VERSION_ID%%.*}")/packages-microsoft-prod.rpm
308+
sudo rpm -i packages-microsoft-prod.rpm
309+
rm packages-microsoft-prod.rpm
310+
dnf update
311+
dnf install -y azfilesauth
312+
```
313+
314+
Sometimes RHEL can block kernel upcall access to the credential cache file. If a failure occurs, see `/var/log/messages` for potential causes.
315+
316+
RHEL uses a persistent credential or KCM cache by default. You can switch to a FILE-based cache for `azfilesauth`:
317+
318+
```bash
319+
sudo tee /etc/krb5.conf.d/00-azfilesauth.conf > /dev/null <<EOF
320+
[libdefaults]
321+
default_ccache_name = FILE:/tmp/krb5cc_%{uid}
322+
EOF
323+
```
324+
325+
#### SLES 15 SP6+
326+
327+
Run the following commands to install `azfilesauth` on SLES 15 SP6+:
328+
329+
```bash
330+
curl -sSL -O https://packages.microsoft.com/config/sles/15/packages-microsoft-prod.rpm
331+
sudo rpm -i packages-microsoft-prod.rpm
332+
rm packages-microsoft-prod.rpm
333+
sudo zypper refresh
334+
sudo zypper install -y azfilesauth
335+
```
336+
337+
SLES 15 SP6+ uses a persistent credential or KCM cache by default. You can switch to a FILE-based cache for `azfilesauth`:
338+
339+
```bash
340+
sudo tee /etc/krb5.conf.d/00-azfilesauth.conf > /dev/null <<EOF
341+
[libdefaults]
342+
default_ccache_name = FILE:/tmp/krb5cc_%{uid}
343+
EOF
344+
```
345+
287346
#### Ubuntu 22.04
288347
289348
Run the following commands to install `azfilesauth` on Ubuntu 22.04:
@@ -314,17 +373,28 @@ sudo apt-get install -y azfilesauth
314373
315374
You have two options for configuring authentication on Linux:
316375
317-
- **Use a VM managed identity:** Select this option when your VM has a user-assigned managed identity assigned.
376+
- **Use a VM managed identity:** Select this option if your VM has a managed identity assigned.
318377
- **Supply the OAuth token directly**: Select this option if you're managing OAuth tokens yourself.
319378
320379
#### Option 1: Use a VM managed identity
321380
322-
If your VM has a user-assigned managed identity, run the following commands. Be sure to replace `<client-id>` with the client ID of your managed identity. If you don't have the Client ID, go to the managed identity and copy the Client ID.
381+
You can use a system assigned or user assigned managed identity to configure authentication.
382+
383+
If your VM has a user assigned managed identity, run the following command to get a token from the Azure Instance Metadata Service (IMDS) and store it automatically. Replace `<client-id>` with the client ID of your managed identity. If you don't have the Client ID, go to the managed identity in the Azure portal and copy the Client ID.
323384
324385
```bash
325-
# Get a token from the Azure Instance Metadata Service (IMDS) and store it automatically
326386
sudo azfilesauthmanager set https://<storage_account>.file.core.windows.net --imds-client-id <client-id>
327-
# Verify the ticket was created properly
387+
```
388+
389+
If your VM has a system assigned managed identity, use the `--system` flag:
390+
391+
```bash
392+
sudo azfilesauthmanager set https://<storage_account>.file.core.windows.net --imds-client-id <client-id> --system
393+
```
394+
395+
Verify the ticket was created properly:
396+
397+
```bash
328398
sudo azfilesauthmanager list
329399
```
330400
@@ -357,10 +427,10 @@ For more information, see [Mount SMB Azure file share on Windows](storage-how-to
357427
358428
### [Linux](#tab/linux)
359429
360-
Run the following command to mount the file share with the recommended mount options. Replace `<storage-account-name>` with your storage account name and `<file-share-name>` with your file share name. You can find your credential ID in the following config file: `cat /etc/azfilesauth/config.yaml`
430+
Run the following command to mount the file share with the recommended mount options. Replace `<storage-account-name>` with your storage account name and `<file-share-name>` with your file share name. You can find your credential ID in the following config file: `cat /etc/azfilesauth/config.yaml`. For a user assigned managed identity, include the client ID of the managed identity. For a system assigned managed identity, omit the mount option `username=<client-id>`.
361431
362432
```bash
363-
sudo mount -t cifs //<storage-account-name>.file.core.windows.net/<file-share-name> /mnt/smb -o sec=krb5,cruid=<credential-id>,dir_mode=0755,file_mode=0755,serverino,nosharesock,mfsymlinks,actimeo=30
433+
sudo mount -t cifs //<storage-account-name>.file.core.windows.net/<file-share-name> /mnt/smb -o sec=krb5,cruid=<credential-id>,username=<client-id>,dir_mode=0755,file_mode=0755,serverino,nosharesock,mfsymlinks,actimeo=30
364434
```
365435
366436
Verify that the mount succeeded:
@@ -373,14 +443,20 @@ For more information, see [Mount SMB Azure file shares on Linux clients](storage
373443
374444
### Refresh your credentials
375445
376-
After you mount the file share for the first time, start the refresh service to keep credentials up to date. You can only refresh credentials if your VM has a user-assigned managed identity assigned. If you're supplying the OAuth token directly, the refresh doesn't work.
446+
The refresh service automatically detects and refreshes credentials. After you mount the file share for the first time, start the refresh service to keep credentials up to date. You can only refresh credentials if your VM has a managed identity assigned. If you're supplying the OAuth token directly, the refresh doesn't work.
377447
378448
```bash
379-
sudo systemctl start azfilesauth
449+
sudo systemctl start azfilesrefresh
380450
```
381451
382452
You should refresh your credentials periodically to avoid access interruptions. You can refresh credentials manually by using the `azfilesauthmanager set` command as described in [Configure authentication](#configure-authentication), or you can automate the refresh by using the shared library APIs.
383453
454+
To persist the settings and enable the refresh service to start on every boot up:
455+
456+
```bash
457+
sudo systemctl enable --now azfilesrefresh
458+
```
459+
384460
---
385461
386462
## Troubleshooting

0 commit comments

Comments
 (0)