You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Use Azure CLI for files & ACLs in Azure Data Lake Storage Gen2 (preview)
2
+
title: Use Azure CLI for files & ACLs in Azure Data Lake Storage Gen2
3
3
description: Use the Azure CLI to manage directories and file and directory access control lists (ACL) in storage accounts that have a hierarchical namespace.
4
4
services: storage
5
5
author: normesta
6
6
ms.service: storage
7
7
ms.subservice: data-lake-storage-gen2
8
8
ms.topic: conceptual
9
-
ms.date: 11/24/2019
9
+
ms.date: 05/11/2020
10
10
ms.author: normesta
11
11
ms.reviewer: prishet
12
12
---
13
13
14
-
# Use Azure CLI to manage directories, files, and ACLs in Azure Data Lake Storage Gen2 (preview)
14
+
# Use Azure CLI to manage directories, files, and ACLs in Azure Data Lake Storage Gen2
15
15
16
16
This article shows you how to use the [Azure Command-Line Interface (CLI)](https://docs.microsoft.com/cli/azure/?view=azure-cli-latest) to create and manage directories, files, and permissions in storage accounts that have a hierarchical namespace.
17
17
18
-
> [!IMPORTANT]
19
-
> The `storage-preview` extension that is featured in this article is currently in public preview.
18
+
[Gen1 to Gen2 mapping](https://github.com/Azure/azure-cli-extensions/tree/master/src/storage-preview#mapping-from-adls-gen1-to-adls-gen2) | [Give feedback](https://github.com/Azure/azure-cli-extensions/issues)
20
19
21
-
[Sample](https://github.com/Azure/azure-cli-extensions/tree/master/src/storage-preview#adls-gen2-support) | [Gen1 to Gen2 mapping](https://github.com/Azure/azure-cli-extensions/tree/master/src/storage-preview#mapping-from-adls-gen1-to-adls-gen2) | [Give feedback](https://github.com/Azure/azure-cli-extensions/issues)
22
20
## Prerequisites
23
21
24
22
> [!div class="checklist"]
25
23
> * An Azure subscription. See [Get Azure free trial](https://azure.microsoft.com/pricing/free-trial/).
26
24
> * A storage account that has hierarchical namespace (HNS) enabled. Follow [these](data-lake-storage-quickstart-create-account.md) instructions to create one.
27
-
> * Azure CLI version `2.0.67` or higher.
25
+
> * Azure CLI version `2.5.1` or higher.
28
26
29
-
## Install the storage CLI extension
27
+
## Ensure that you have the correct version of Azure CLI installed
30
28
31
29
1. Open the [Azure Cloud Shell](https://docs.microsoft.com/azure/cloud-shell/overview?view=azure-cli-latest), or if you've [installed](https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli-latest) the Azure CLI locally, open a command console application such as Windows PowerShell.
32
30
33
-
2. Verify that the version of Azure CLI that have installed is `2.0.67` or higher by using the following command.
31
+
2. Verify that the version of Azure CLI that have installed is `2.5.1` or higher by using the following command.
34
32
35
33
```azurecli
36
34
az --version
37
35
```
38
-
If your version of Azure CLI is lower than `2.0.67`, then install a later version. See [Install the Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli-latest).
39
-
40
-
3. Install the `storage-preview` extension.
41
-
42
-
```azurecli
43
-
az extension add -n storage-preview
44
-
```
36
+
If your version of Azure CLI is lower than `2.5.1`, then install a later version. See [Install the Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli-latest).
45
37
46
38
## Connect to the account
47
39
@@ -55,7 +47,7 @@ This article shows you how to use the [Azure Command-Line Interface (CLI)](https
55
47
56
48
Otherwise, open a browser page at [https://aka.ms/devicelogin](https://aka.ms/devicelogin) and enter the authorization code displayed in your terminal. Then, sign in with your account credentials in the browser.
57
49
58
-
To learn more about different authentication methods, see Sign in with Azure CLI.
50
+
To learn more about different authentication methods, see [Authorize access to blob or queue data with Azure CLI](../common/authorize-data-operations-cli.md).
59
51
60
52
2. If your identity is associated with more than one subscription, then set your active subscription to subscription of the storage account that will host your static website.
61
53
@@ -65,132 +57,157 @@ This article shows you how to use the [Azure Command-Line Interface (CLI)](https
65
57
66
58
Replace the `<subscription-id>` placeholder value with the ID of your subscription.
67
59
60
+
> [!NOTE]
61
+
> The example presented in this article show Azure Active Directory (AD) authorization. To learn more about authorization methods, see [Authorize access to blob or queue data with Azure CLI](../common/authorize-data-operations-cli.md).
62
+
68
63
## Create a file system
69
64
70
-
A file system acts as a container for your files. You can create one by using the `az storage container create` command.
65
+
A file system acts as a container for your files. You can create one by using the `az storage fs create` command.
71
66
72
67
This example creates a file system named `my-file-system`.
73
68
74
69
```azurecli
75
-
az storage container create --name my-file-system --account-name mystorageaccount
70
+
az storage fs create -n my-file-system --account-name mystorageaccount --auth-mode login
71
+
```
72
+
73
+
## Show file system properties
74
+
75
+
You can print the properties of a file system to the console by using the `az storage fs show` command.
76
+
77
+
```azurecli
78
+
az storage fs show -n my-file-system --account-name mystorageaccount --auth-mode login
79
+
```
80
+
81
+
## List file system contents
82
+
83
+
List the contents of a directory by using the `az storage fs file list` command.
84
+
85
+
This example lists the contents of a file system named `my-file-system`.
86
+
87
+
```azurecli
88
+
az storage fs file list -f my-file-system --account-name mystorageaccount --auth-mode login
89
+
```
90
+
91
+
## Delete a file system
92
+
93
+
Delete a file system by using the `az storage fs delete` command.
94
+
95
+
This example deletes a file system named `my-file-system`.
96
+
97
+
```azurecli
98
+
az storage fs delete -n my-file-system --account-name mystorageaccount --auth-mode login
76
99
```
77
100
78
101
## Create a directory
79
102
80
-
Create a directory reference by using the `az storage blob directory create` command.
103
+
Create a directory reference by using the `az storage fs directory create` command.
81
104
82
105
This example adds a directory named `my-directory` to a file system named `my-file-system` that is located in an account named `mystorageaccount`.
List the contents of a directory by using the `az storage blob directory list` command.
167
+
List the contents of a directory by using the `az storage fs file list` command.
145
168
146
169
This example lists the contents of a directory named `my-directory` that is located in the `my-file-system` file system of a storage account named `mystorageaccount`.
147
170
148
171
```azurecli
149
-
az storage blob directory list -c my-file-system -d my-directory --account-name mystorageaccount
172
+
az storage fs file list -f my-file-system --path my-directory --account-name mystorageaccount --auth-mode login
150
173
```
151
174
152
175
## Upload a file to a directory
153
176
154
-
Upload a file to a directory by using the `az storage blob directory upload` command.
177
+
Upload a file to a directory by using the `az storage fs directory upload` command.
155
178
156
179
This example uploads a file named `upload.txt` to a directory named `my-directory`.
@@ -200,22 +217,22 @@ You can get, set, and update access permissions of directories and files.
200
217
> [!NOTE]
201
218
> If you're using Azure Active Directory (Azure AD) to authorize commands, then make sure that your security principal has been assigned the [Storage Blob Data Owner role](https://docs.microsoft.com/azure/role-based-access-control/built-in-roles#storage-blob-data-owner). To learn more about how ACL permissions are applied and the effects of changing them, see [Access control in Azure Data Lake Storage Gen2](https://docs.microsoft.com/azure/storage/blobs/data-lake-storage-access-control).
202
219
203
-
### Get directory and file permissions
220
+
### Get an ACL
204
221
205
-
Get the ACL of a **directory** by using the `az storage blob directory access show` command.
222
+
Get the ACL of a **directory** by using the `az storage fs access show` command.
206
223
207
224
This example gets the ACL of a directory, and then prints the ACL to the console.
208
225
209
226
```azurecli
210
-
az storage blob directory access show -d my-directory -c my-file-system --account-name mystorageaccount
227
+
az storage fs access show -p my-directory -f my-file-system --account-name mystorageaccount --auth-mode login
211
228
```
212
229
213
-
Get the access permissions of a **file** by using the `az storage blob access show` command.
230
+
Get the access permissions of a **file** by using the `az storage fs access show` command.
214
231
215
232
This example gets the ACL of a file and then prints the ACL to the console.
216
233
217
234
```azurecli
218
-
az storage blob access show -b my-directory/upload.txt -c my-file-system --account-name mystorageaccount
235
+
az storage fs access show -p my-directory/upload.txt -f my-file-system --account-name mystorageaccount --auth-mode login
219
236
```
220
237
221
238
The following image shows the output after getting the ACL of a directory.
@@ -224,87 +241,72 @@ The following image shows the output after getting the ACL of a directory.
224
241
225
242
In this example, the owning user has read, write, and execute permissions. The owning group has only read and execute permissions. For more information about access control lists, see [Access control in Azure Data Lake Storage Gen2](data-lake-storage-access-control.md).
226
243
227
-
### Set directory and file permissions
244
+
### Set an ACL
228
245
229
-
Use the `az storage blob directory access set` command to set the ACL of a **directory**.
246
+
Use the `az storage fs access set` command to set the ACL of a **directory**.
230
247
231
248
This example sets the ACL on a directory for the owning user, owning group, or other users, and then prints the ACL to the console.
232
249
233
250
```azurecli
234
-
az storage blob directory access set -a "user::rw-,group::rw-,other::-wx" -d my-directory -c my-file-system --account-name mystorageaccount
251
+
az storage fs access set --acl "user::rw-,group::rw-,other::-wx" -p my-directory -f my-file-system --account-name mystorageaccount --auth-mode login
235
252
```
236
253
237
254
This example sets the *default* ACL on a directory for the owning user, owning group, or other users, and then prints the ACL to the console.
238
255
239
256
```azurecli
240
-
az storage blob directory access set -a "default:user::rw-,group::rw-,other::-wx" -d my-directory -c my-file-system --account-name mystorageaccount
257
+
az storage fs access set --acl "default:user::rw-,group::rw-,other::-wx" -p my-directory -f my-file-system --account-name mystorageaccount --auth-mode login
241
258
```
242
259
243
-
Use the `az storage blob access set` command to set the acl of a **file**.
260
+
Use the `az storage fs access set` command to set the acl of a **file**.
244
261
245
262
This example sets the ACL on a file for the owning user, owning group, or other users, and then prints the ACL to the console.
246
263
247
264
```azurecli
248
-
az storage blob access set -a "user::rw-,group::rw-,other::-wx" -b my-directory/upload.txt -c my-file-system --account-name mystorageaccount
265
+
az storage fs access set --acl "user::rw-,group::rw-,other::-wx" -p my-directory/upload.txt -f my-file-system --account-name mystorageaccount --auth-mode login
249
266
```
267
+
250
268
The following image shows the output after setting the ACL of a file.
In this example, the owning user and owning group have only read and write permissions. All other users have write and execute permissions. For more information about access control lists, see [Access control in Azure Data Lake Storage Gen2](data-lake-storage-access-control.md).
255
273
256
-
### Update directory and file permissions
274
+
### Update an ACL
257
275
258
-
Another way to set this permission is to use the `az storage blob directory access update` or `az storage blob access update` command.
276
+
Another way to set this permission is to use the `az storage fs access set` command.
259
277
260
278
Update the ACL of a directory or file by setting the `-permissions` parameter to the short form of an ACL.
az storage fs access set --permissions rwxrwxrwx -p my-directory/upload.txt -f my-file-system --account-name mystorageaccount --auth-mode login
272
290
```
273
291
274
292
You can also update the owning user and group of a directory or file by setting the `--owner` or `group` parameters to the entity ID or User Principal Name (UPN) of a user.
You can add user-defined metadata to a file or directory by using the `az storage blob directory metadata update` command with one or more name-value pairs.
290
-
291
-
This example adds user-defined metadata for a directory named `my-directory` directory.
0 commit comments