Skip to content

Commit 51bb7c6

Browse files
committed
[Storage] Support NFS symbolicLink
1 parent bd74a9a commit 51bb7c6

File tree

11 files changed

+932
-11
lines changed

11 files changed

+932
-11
lines changed

src/Storage/Storage.Management.Test/Storage.Management.Test.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Azure.Storage.Blobs" Version="12.24.0" />
15-
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.22.0" />
16-
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.22.0" />
17-
<PackageReference Include="Azure.Storage.Queues" Version="12.22.0" />
14+
<PackageReference Include="Azure.Storage.Blobs" Version="12.25.0" />
15+
<PackageReference Include="Azure.Storage.Files.DataLake" Version="12.23.0" />
16+
<PackageReference Include="Azure.Storage.Files.Shares" Version="12.23.0" />
17+
<PackageReference Include="Azure.Storage.Queues" Version="12.23.0" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

src/Storage/Storage.Management/Az.Storage.psd1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ CmdletsToExport = 'Add-AzRmStorageContainerLegalHold',
208208
'Update-AzStorageBlobServiceProperty',
209209
'Update-AzStorageEncryptionScope',
210210
'Update-AzStorageFileServiceProperty',
211-
'Update-AzStorageServiceProperty'
211+
'Update-AzStorageServiceProperty',
212+
'New-AzStorageFileSymbolicLink',
213+
'Get-AzStorageFileSymbolicLink'
212214

213215
# Variables to export from this module
214216
# VariablesToExport = @()

src/Storage/Storage.Management/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
- `Set-AzStorageAccount`
2424
* Supported Enable Metrics when set object replication policy
2525
- `Set-AzStorageObjectReplicationPolicy`
26+
* Supported create and get symbolic link in NFS File Share
27+
- `New-AzStorageFileSymbolicLink`
28+
- `Get-AzStorageFileSymbolicLink`
2629

2730
## Version 9.1.0
2831
* Supported set SasExpirationAction as Log or Block, together with SasExpirationPeriod

src/Storage/Storage.Management/help/Az.Storage.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ Gets service properties for Azure Storage File services.
155155
### [Get-AzStorageFileServiceUsage](Get-AzStorageFileServiceUsage.md)
156156
Gets the usage of file service in storage account including account limits, file share limits and constants used in recommendations and bursting formula.
157157

158+
### [Get-AzStorageFileServiceUsage](Get-AzStorageFileServiceUsage.md)
159+
Gets the value of a symoblic link. Only works in NFS file share.
160+
158161
### [Get-AzStorageLocalUser](Get-AzStorageLocalUser.md)
159162
Gets a specified local user or lists all local users in a storage account.
160163

@@ -281,6 +284,9 @@ Creates a hard link to a file in same share. Only works in NFS file share.
281284
### [New-AzStorageFileSASToken](New-AzStorageFileSASToken.md)
282285
Generates a shared access signature token for a Storage file.
283286

287+
### [New-AzStorageFileSymbolicLink](New-AzStorageFileSymbolicLink.md)
288+
Creates a symbolic link to a specified file. Only works in NFS file share.
289+
284290
### [New-AzStorageLocalUserPermissionScope](New-AzStorageLocalUserPermissionScope.md)
285291
Creates a permission scope object, which can be used in Set-AzStorageLocalUser.
286292

Lines changed: 293 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,293 @@
1+
---
2+
external help file: Microsoft.Azure.PowerShell.Cmdlets.Storage.dll-Help.xml
3+
Module Name: Az.Storage
4+
online version: https://learn.microsoft.com/powershell/module/az.storage/get-azstoragefilesymboliclink
5+
schema: 2.0.0
6+
---
7+
8+
# Get-AzStorageFileSymbolicLink
9+
10+
## SYNOPSIS
11+
Gets the properties of a symbolic link. Only works in NFS file share.
12+
13+
## SYNTAX
14+
15+
### ShareName (Default)
16+
```
17+
Get-AzStorageFileSymbolicLink [-ShareName] <String> [-Path] <String> [-Context <IStorageContext>]
18+
[-ServerTimeoutPerRequest <Int32>] [-ClientTimeoutPerRequest <Int32>]
19+
[-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>] [<CommonParameters>]
20+
```
21+
22+
### Share
23+
```
24+
Get-AzStorageFileSymbolicLink [-ShareClient] <ShareClient> [-Path] <String> [-Context <IStorageContext>]
25+
[-ServerTimeoutPerRequest <Int32>] [-ClientTimeoutPerRequest <Int32>]
26+
[-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>] [<CommonParameters>]
27+
```
28+
29+
### Directory
30+
```
31+
Get-AzStorageFileSymbolicLink [-ShareDirectoryClient] <ShareDirectoryClient> [-Path] <String>
32+
[-Context <IStorageContext>] [-ServerTimeoutPerRequest <Int32>] [-ClientTimeoutPerRequest <Int32>]
33+
[-DefaultProfile <IAzureContextContainer>] [-ConcurrentTaskCount <Int32>] [<CommonParameters>]
34+
```
35+
36+
## DESCRIPTION
37+
The **Get-AzStorageFileSymbolicLink** cmdlet retrieves the properties and target path of a symbolic link in an Azure File share. This cmdlet only works with NFS file shares.
38+
39+
## EXAMPLES
40+
41+
### Example 1: Get symbolic link properties using share name
42+
```powershell
43+
$ctx = New-AzStorageContext -StorageAccountName "myaccount" -EnableFileBackupRequestIntent
44+
$link = Get-AzStorageFileSymbolicLink -ShareName "nfsshare" -Path "linkdir/mylink" -Context $ctx
45+
$link
46+
$link.FileProperties
47+
$link.FileProperties.PosixProperties
48+
$link.ShareFileSymbolicLinkInfo
49+
```
50+
51+
```output
52+
AccountName: myaccount, ShareName: nfsshare
53+
54+
Type Length Name Path
55+
---- ------ ---- ----
56+
File 0 mylink linkdir/mylink
57+
58+
LastModified : 9/17/2025 8:36:43 AM +00:00
59+
Metadata : {}
60+
ContentLength : 13
61+
ContentType : application/octet-stream
62+
ETag : "0x8DDF5C554DCC708"
63+
ContentHash :
64+
ContentEncoding :
65+
CacheControl :
66+
ContentDisposition :
67+
ContentLanguage :
68+
CopyCompletedOn : 1/1/0001 12:00:00 AM +00:00
69+
CopyStatusDescription :
70+
CopyId :
71+
CopyProgress :
72+
CopySource :
73+
CopyStatus : Pending
74+
IsServerEncrypted : True
75+
SmbProperties : Azure.Storage.Files.Shares.Models.FileSmbProperties
76+
LeaseDuration : Infinite
77+
LeaseState : Available
78+
LeaseStatus : Unlocked
79+
PosixProperties : Azure.Storage.Files.Shares.Models.FilePosixProperties
80+
81+
82+
FileMode : rwxrwxrwx
83+
Owner : 0
84+
Group : 0
85+
FileType : SymLink
86+
LinkCount : 1
87+
88+
89+
ETag : "0x8DDF5C554DCC708"
90+
LastModified : 9/17/2025 8:36:43 AM +00:00
91+
LinkText : app%2Fmain.exe
92+
```
93+
94+
This command gets the properties of a symbolic link named "mylink" in the "links" directory of the NFS file share "nfsshare".
95+
96+
### Example 2: Get multiple symbolic links in a directory
97+
```powershell
98+
$files = Get-AzStorageFile -ShareName "nfsshare" -Path "linkdir" -Context $ctx | Get-AzStorageFile -ExcludeExtendedInfo
99+
$symLinkFiles = $files | ? {$_.FileProperties.PosixProperties.FileType -eq "SymLink"}
100+
foreach ($file in $symLinkFiles) {
101+
$symlink = Get-AzStorageFileSymbolicLink -ShareName "nfsshare" -Path "linkdir/$($file.Name)" -Context $ctx
102+
Write-Output "$($file.Name) -> $([System.Web.HttpUtility]::UrlDecode($symlink.ShareFileSymbolicLinkInfo.LinkText))"
103+
}
104+
```
105+
106+
This command first lists all files in "linkdir" directory , then filter out all files which are symbolic link, finally gets symbolic link properties for each file.
107+
108+
### Example 3: Get symbolic link using ShareClient pipeline
109+
```powershell
110+
$ctx = New-AzStorageContext -StorageAccountName "myaccount" -EnableFileBackupRequestIntent
111+
$shareClient = Get-AzStorageShare -Name "nfsshare" -Context $ctx
112+
$link = $shareClient | Get-AzStorageFileSymbolicLink -Path "linkdir/mylink"
113+
```
114+
115+
This command gets a symbolic link using a ShareClient object obtained from Get-AzStorageShare, demonstrating the pipeline usage with the Share parameter set.
116+
117+
### Example 4: Get symbolic link using ShareDirectoryClient pipeline
118+
```powershell
119+
$ctx = New-AzStorageContext -StorageAccountName "myaccount" -EnableFileBackupRequestIntent
120+
$dirClient = Get-AzStorageFile -ShareName "nfsshare" -Path "linkdir" -Context $ctx
121+
$link = $dirClient | Get-AzStorageFileSymbolicLink -Path "mylink"
122+
```
123+
124+
This command gets a symbolic link within a specific directory using a ShareDirectoryClient object, demonstrating the pipeline usage with the Directory parameter set.
125+
126+
## PARAMETERS
127+
128+
### -ClientTimeoutPerRequest
129+
The client side maximum execution time for each request in seconds.
130+
131+
```yaml
132+
Type: System.Nullable`1[System.Int32]
133+
Parameter Sets: (All)
134+
Aliases: ClientTimeoutPerRequestInSeconds
135+
136+
Required: False
137+
Position: Named
138+
Default value: None
139+
Accept pipeline input: False
140+
Accept wildcard characters: False
141+
```
142+
143+
### -ConcurrentTaskCount
144+
The total amount of concurrent async tasks.
145+
The default value is 10.
146+
147+
```yaml
148+
Type: System.Nullable`1[System.Int32]
149+
Parameter Sets: (All)
150+
Aliases:
151+
152+
Required: False
153+
Position: Named
154+
Default value: None
155+
Accept pipeline input: False
156+
Accept wildcard characters: False
157+
```
158+
159+
### -Context
160+
Azure Storage Context Object
161+
162+
```yaml
163+
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.IStorageContext
164+
Parameter Sets: (All)
165+
Aliases:
166+
167+
Required: False
168+
Position: Named
169+
Default value: None
170+
Accept pipeline input: True (ByPropertyName, ByValue)
171+
Accept wildcard characters: False
172+
```
173+
174+
### -DefaultProfile
175+
The credentials, account, tenant, and subscription used for communication with Azure.
176+
177+
```yaml
178+
Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer
179+
Parameter Sets: (All)
180+
Aliases: AzureRmContext, AzureCredential
181+
182+
Required: False
183+
Position: Named
184+
Default value: None
185+
Accept pipeline input: False
186+
Accept wildcard characters: False
187+
```
188+
189+
### -Path
190+
Path of the symbolic link file to retrieve.
191+
192+
```yaml
193+
Type: System.String
194+
Parameter Sets: (All)
195+
Aliases:
196+
197+
Required: True
198+
Position: 1
199+
Default value: None
200+
Accept pipeline input: True (ByPropertyName, ByValue)
201+
Accept wildcard characters: False
202+
```
203+
204+
### -ServerTimeoutPerRequest
205+
The server time out for each request in seconds.
206+
207+
```yaml
208+
Type: System.Nullable`1[System.Int32]
209+
Parameter Sets: (All)
210+
Aliases: ServerTimeoutPerRequestInSeconds
211+
212+
Required: False
213+
Position: Named
214+
Default value: None
215+
Accept pipeline input: False
216+
Accept wildcard characters: False
217+
```
218+
219+
### -ShareClient
220+
ShareClient object indicating the share containing the symbolic link.
221+
222+
```yaml
223+
Type: Azure.Storage.Files.Shares.ShareClient
224+
Parameter Sets: Share
225+
Aliases:
226+
227+
Required: True
228+
Position: 0
229+
Default value: None
230+
Accept pipeline input: True (ByPropertyName, ByValue)
231+
Accept wildcard characters: False
232+
```
233+
234+
### -ShareDirectoryClient
235+
ShareDirectoryClient object indicating the base folder containing the symbolic link.
236+
237+
```yaml
238+
Type: Azure.Storage.Files.Shares.ShareDirectoryClient
239+
Parameter Sets: Directory
240+
Aliases:
241+
242+
Required: True
243+
Position: 0
244+
Default value: None
245+
Accept pipeline input: True (ByPropertyName, ByValue)
246+
Accept wildcard characters: False
247+
```
248+
249+
### -ShareName
250+
Name of the file share containing the symbolic link.
251+
252+
```yaml
253+
Type: System.String
254+
Parameter Sets: ShareName
255+
Aliases:
256+
257+
Required: True
258+
Position: 0
259+
Default value: None
260+
Accept pipeline input: False
261+
Accept wildcard characters: False
262+
```
263+
264+
### CommonParameters
265+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
266+
267+
## INPUTS
268+
269+
### Azure.Storage.Files.Shares.ShareClient
270+
271+
### Azure.Storage.Files.Shares.ShareDirectoryClient
272+
273+
### System.String
274+
275+
### Microsoft.Azure.Commands.Common.Authentication.Abstractions.IStorageContext
276+
277+
## OUTPUTS
278+
279+
### Microsoft.WindowsAzure.Commands.Common.Storage.ResourceModel.AzureStorageFile
280+
281+
## NOTES
282+
- This cmdlet only works with NFS file shares
283+
- The returned object contains the symbolic link properties including the target path (LinkText)
284+
- Use the FileProperties.LinkText property to access the target path of the symbolic link
285+
- The FileProperties.IsSymbolicLink property can be used to verify the file is indeed a symbolic link
286+
287+
## RELATED LINKS
288+
289+
[New-AzStorageFileSymbolicLink](./New-AzStorageFileSymbolicLink.md)
290+
291+
[Get-AzStorageFile](./Get-AzStorageFile.md)
292+
293+
[New-AzStorageFileHardLink](./New-AzStorageFileHardLink.md)

0 commit comments

Comments
 (0)