Skip to content

Commit 7165fda

Browse files
authored
Merge pull request #98862 from normesta/normesta-sdk-interop
Adding context and auth details
2 parents b1d024f + 13d0ac8 commit 7165fda

File tree

1 file changed

+30
-28
lines changed

1 file changed

+30
-28
lines changed

articles/storage/blobs/data-lake-storage-directory-file-acl-powershell.md

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,37 +54,36 @@ This article shows you how to use PowerShell to create and manage directories, f
5454
5555
## Connect to the account
5656
57-
1. Open a Windows PowerShell command window.
57+
Open a Windows PowerShell command window, and then sign in to your Azure subscription with the `Connect-AzAccount` command and follow the on-screen directions.
5858
59-
2. Sign in to your Azure subscription with the `Connect-AzAccount` command and follow the on-screen directions.
60-
61-
```powershell
62-
Connect-AzAccount
63-
```
59+
```powershell
60+
Connect-AzAccount
61+
```
6462

65-
3. If your identity is associated with more than one subscription, then set your active subscription to subscription of the storage account that you want create and manage directories in.
63+
If your identity is associated with more than one subscription, then set your active subscription to subscription of the storage account that you want create and manage directories in. In this example, replace the `<subscription-id>` placeholder value with the ID of your subscription.
6664

67-
```powershell
68-
Select-AzSubscription -SubscriptionId <subscription-id>
69-
```
65+
```powershell
66+
Select-AzSubscription -SubscriptionId <subscription-id>
67+
```
7068

71-
Replace the `<subscription-id>` placeholder value with the ID of your subscription.
69+
Next, choose how you want your commands to obtain authorization to the storage account.
7270

73-
4. Get the storage account.
71+
### Option 1: Obtain authorization by using Azure Active Directory (AD)
7472

75-
```powershell
76-
$storageAccount = Get-AzStorageAccount -ResourceGroupName "<resource-group-name>" -AccountName "<storage-account-name>"
77-
```
73+
With this approach, the system ensures that your user account has the appropriate role-based access control (RBAC) assignments and ACL permissions.
7874

79-
* Replace the `<resource-group-name>` placeholder value with the name of your resource group.
75+
```powershell
76+
$ctx = New-AzStorageContext -StorageAccountName '<storage-account-name>' -UseConnectedAccount
77+
```
8078

81-
* Replace the `<storage-account-name>` placeholder value with the name of your storage account.
79+
### Option 2: Obtain authorization by using the storage account key
8280

83-
5. Get the storage account context.
81+
With this approach, the system doesn't check the RBAC or ACL permissions of a resource.
8482

85-
```powershell
86-
$ctx = $storageAccount.Context
87-
```
83+
```powershell
84+
$storageAccount = Get-AzStorageAccount -ResourceGroupName "<resource-group-name>" -AccountName "<storage-account-name>"
85+
$ctx = $storageAccount.Context
86+
```
8887

8988
## Create a file system
9089

@@ -184,27 +183,30 @@ Get-AzDataLakeGen2ItemContent -Context $ctx -FileSystem $filesystemName -Path $f
184183

185184
List the contents of a directory by using the `Get-AzDataLakeGen2ChildItem` cmdlet.
186185

187-
This example lists the contents of a directory named `my-directory`.
188-
189-
To list the contents of a file system, omit the `-Path` parameter from the command.
186+
This example lists the contents of a directory named `my-directory`.
190187

191188
```powershell
192189
$filesystemName = "my-file-system"
193190
$dirname = "my-directory/"
194191
Get-AzDataLakeGen2ChildItem -Context $ctx -FileSystem $filesystemName -Path $dirname
195192
```
196193

197-
This example lists the contents of a directory named `my-directory` and includes ACLs in the list.
198-
It also uses the `-Recurse` parameter to list the contents of all subdirectories.
194+
This example doesn't return values for the `ACL`, `Permissions`, `Group`, and `Owner` properties. To obtain those values, use the `-FetchPermission` parameter.
199195

200-
To list the contents of a file system, omit the `-Path` parameter from the command.
196+
The following example lists the contents of the same directory, but it also uses the `-FetchPermission` parameter to return values for the `ACL`, `Permissions`, `Group`, and `Owner` properties.
201197

202198
```powershell
203199
$filesystemName = "my-file-system"
204200
$dirname = "my-directory/"
205-
Get-AzDataLakeGen2ChildItem -Context $ctx -FileSystem $filesystemName -Path $dirname -Recurse -FetchPermission
201+
$properties = Get-AzDataLakeGen2ChildItem -Context $ctx -FileSystem $filesystemName -Path $dirname -Recurse -FetchPermission
202+
$properties.ACL
203+
$properties.Permissions
204+
$properties.Group
205+
$properties.Owner
206206
```
207207

208+
To list the contents of a file system, omit the `-Path` parameter from the command.
209+
208210
## Upload a file to a directory
209211

210212
Upload a file to a directory by using the `New-AzDataLakeGen2Item` cmdlet.

0 commit comments

Comments
 (0)