Skip to content

Commit 8a9a130

Browse files
Merge pull request #313230 from khdownie/kendownie031626
Add system assigned MI for Linux
2 parents 23c2d9c + 0a7e4ec commit 8a9a130

1 file changed

Lines changed: 100 additions & 22 deletions

File tree

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

Lines changed: 100 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: This article explains how you can authenticate managed identities t
44
author: khdownie
55
ms.service: azure-file-storage
66
ms.topic: how-to
7-
ms.date: 03/04/2026
7+
ms.date: 03/16/2026
88
ms.author: kendownie
99
ms.custom:
1010
- devx-track-azurepowershell
@@ -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,27 @@ 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 managed identities, Azure defaults to system assigned. Assign only one for best results.
196+
197+
#### Enable a system assigned managed identity
195198

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).
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+
:::image type="content" source="media/managed-identities/enable-system-assigned-managed-identity.png" alt-text="Screenshot showing how to enable system assigned managed identity when creating a new VM using the Azure portal." border="true":::
197204

198-
1. Go to the managed identity you just created and copy the **Client ID**. You need this value later.
205+
#### Enable a user assigned managed identity
206+
207+
1. Sign in to the Azure portal and follow the steps to [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).
208+
209+
1. Go to the user assigned managed identity you just created and copy the **Client ID**. You need this value later.
210+
211+
### Assign a built-in RBAC role to the managed identity
199212

200213
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.
201214

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

208221
1. Under **Members**, select **+ Select members**. The **Select managed identities** pane appears.
209222

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

212225
1. You should now see the managed identity listed under **Members**. Select **Next**.
213226

214227
1. Select **Review + assign** to add the role assignment to the storage account.
215228

229+
### Add user assigned managed identity to VM
230+
231+
If you created a user assigned managed identity, follow these steps to add it to your VM.
232+
216233
1. Go to your VM. From the service menu, under **Security**, select **Identity**.
217234

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**.
235+
1. Select the **User assigned** tab, and then select **Add user assigned managed identity**. Select the managed identity you created, and then select **Add**.
219236

220237
---
221238

@@ -284,6 +301,50 @@ tdnf update
284301
tdnf install azfilesauth
285302
```
286303

304+
#### RHEL 9.6+
305+
306+
Run the following commands to install `azfilesauth` on RHEL 9.6+:
307+
308+
```bash
309+
curl -sSL -O https://packages.microsoft.com/config/$(source /etc/os-release && echo "$ID/${VERSION_ID%%.*}")/packages-microsoft-prod.rpm
310+
sudo rpm -i packages-microsoft-prod.rpm
311+
rm packages-microsoft-prod.rpm
312+
dnf update
313+
dnf install -y azfilesauth
314+
```
315+
316+
Sometimes RHEL can block kernel upcall access to the credential cache file. If a failure occurs, see `/var/log/messages` for potential causes.
317+
318+
RHEL uses a persistent credential or KCM cache by default. You can switch to a FILE-based cache for `azfilesauth`:
319+
320+
```bash
321+
sudo tee /etc/krb5.conf.d/00-azfilesauth.conf > /dev/null <<EOF
322+
[libdefaults]
323+
default_ccache_name = FILE:/tmp/krb5cc_%{uid}
324+
EOF
325+
```
326+
327+
#### SLES 15 SP6+
328+
329+
Run the following commands to install `azfilesauth` on SLES 15 SP6+:
330+
331+
```bash
332+
curl -sSL -O https://packages.microsoft.com/config/sles/15/packages-microsoft-prod.rpm
333+
sudo rpm -i packages-microsoft-prod.rpm
334+
rm packages-microsoft-prod.rpm
335+
sudo zypper refresh
336+
sudo zypper install -y azfilesauth
337+
```
338+
339+
SLES 15 SP6+ uses a persistent credential or KCM cache by default. You can switch to a FILE-based cache for `azfilesauth`:
340+
341+
```bash
342+
sudo tee /etc/krb5.conf.d/00-azfilesauth.conf > /dev/null <<EOF
343+
[libdefaults]
344+
default_ccache_name = FILE:/tmp/krb5cc_%{uid}
345+
EOF
346+
```
347+
287348
#### Ubuntu 22.04
288349
289350
Run the following commands to install `azfilesauth` on Ubuntu 22.04:
@@ -314,17 +375,28 @@ sudo apt-get install -y azfilesauth
314375
315376
You have two options for configuring authentication on Linux:
316377
317-
- **Use a VM managed identity:** Select this option when your VM has a user-assigned managed identity assigned.
378+
- **Use a VM managed identity:** Select this option if your VM has a managed identity assigned.
318379
- **Supply the OAuth token directly**: Select this option if you're managing OAuth tokens yourself.
319380
320381
#### Option 1: Use a VM managed identity
321382
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.
383+
You can use a system assigned or user assigned managed identity to configure authentication.
384+
385+
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 `<storage-account-name>` with your storage account name. 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.
386+
387+
```bash
388+
sudo azfilesauthmanager set https://<storage-account-name>.file.core.windows.net --imds-client-id <client-id>
389+
```
390+
391+
If your VM has a system assigned managed identity, use the `--system` flag:
392+
393+
```bash
394+
sudo azfilesauthmanager set https://<storage-account-name>.file.core.windows.net --imds-client-id <client-id> --system
395+
```
396+
397+
Verify the ticket was created properly:
323398
324399
```bash
325-
# Get a token from the Azure Instance Metadata Service (IMDS) and store it automatically
326-
sudo azfilesauthmanager set https://<storage_account>.file.core.windows.net --imds-client-id <client-id>
327-
# Verify the ticket was created properly
328400
sudo azfilesauthmanager list
329401
```
330402
@@ -357,10 +429,10 @@ For more information, see [Mount SMB Azure file share on Windows](storage-how-to
357429
358430
### [Linux](#tab/linux)
359431
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`
432+
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>`.
361433
362434
```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
435+
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
364436
```
365437
366438
Verify that the mount succeeded:
@@ -373,14 +445,20 @@ For more information, see [Mount SMB Azure file shares on Linux clients](storage
373445
374446
### Refresh your credentials
375447
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.
448+
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.
377449
378450
```bash
379-
sudo systemctl start azfilesauth
451+
sudo systemctl start azfilesrefresh
380452
```
381453
382454
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.
383455
456+
To persist the settings and enable the refresh service to start on every boot up:
457+
458+
```bash
459+
sudo systemctl enable --now azfilesrefresh
460+
```
461+
384462
---
385463
386464
## Troubleshooting
@@ -443,7 +521,7 @@ extern "C" AZFILESSMBMI_API HRESULT SmbClearCredential(
443521
444522
### [Linux](#tab/linux)
445523
446-
Linux developers can use the shared library that's automatically installed with the azfilesauth package. You can link against the library in your C/C++ applications for direct API access.
524+
Linux developers can use the shared library that's automatically installed with the `azfilesauth` package. You can link against the library in your C/C++ applications for direct API access.
447525
448526
Be sure to include the [public header](https://github.com/Azure/AzFilesAuthenticator/blob/main/include/azfilesauth.h).
449527

0 commit comments

Comments
 (0)