Skip to content

Commit 1729222

Browse files
Merge pull request #114578 from normesta/normesta-sdk-interop
Normesta sdk interop
2 parents 42da76c + 8f18443 commit 1729222

File tree

2 files changed

+90
-89
lines changed

2 files changed

+90
-89
lines changed
Lines changed: 90 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,39 @@
11
---
2-
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
33
description: Use the Azure CLI to manage directories and file and directory access control lists (ACL) in storage accounts that have a hierarchical namespace.
44
services: storage
55
author: normesta
66
ms.service: storage
77
ms.subservice: data-lake-storage-gen2
88
ms.topic: conceptual
9-
ms.date: 11/24/2019
9+
ms.date: 05/11/2020
1010
ms.author: normesta
1111
ms.reviewer: prishet
1212
---
1313

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
1515

1616
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.
1717

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)
2019

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)
2220
## Prerequisites
2321

2422
> [!div class="checklist"]
2523
> * An Azure subscription. See [Get Azure free trial](https://azure.microsoft.com/pricing/free-trial/).
2624
> * 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.
2826
29-
## Install the storage CLI extension
27+
## Ensure that you have the correct version of Azure CLI installed
3028

3129
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.
3230

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.
3432

3533
```azurecli
3634
az --version
3735
```
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).
4537

4638
## Connect to the account
4739

@@ -55,7 +47,7 @@ This article shows you how to use the [Azure Command-Line Interface (CLI)](https
5547

5648
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.
5749

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).
5951

6052
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.
6153

@@ -65,132 +57,157 @@ This article shows you how to use the [Azure Command-Line Interface (CLI)](https
6557

6658
Replace the `<subscription-id>` placeholder value with the ID of your subscription.
6759

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+
6863
## Create a file system
6964

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.
7166

7267
This example creates a file system named `my-file-system`.
7368

7469
```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
7699
```
77100

78101
## Create a directory
79102

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.
81104

82105
This example adds a directory named `my-directory` to a file system named `my-file-system` that is located in an account named `mystorageaccount`.
83106

84107
```azurecli
85-
az storage blob directory create -c my-file-system -d my-directory --account-name mystorageaccount
108+
az storage fs directory create -n my-directory -f my-file-system --account-name mystorageaccount --auth-mode login
86109
```
87110

88111
## Show directory properties
89112

90-
You can print the properties of a directory to the console by using the `az storage blob show` command.
113+
You can print the properties of a directory to the console by using the `az storage fs directory show` command.
91114

92115
```azurecli
93-
az storage blob directory show -c my-file-system -d my-directory --account-name mystorageaccount
116+
az storage fs directory show -n my-directory -f my-file-system --account-name mystorageaccount --auth-mode login
94117
```
95118

96119
## Rename or move a directory
97120

98-
Rename or move a directory by using the `az storage blob directory move` command.
121+
Rename or move a directory by using the `az storage fs directory move` command.
99122

100-
This example renames a directory from the name `my-directory` to the name `my-new-directory`.
123+
This example renames a directory from the name `my-directory` to the name `my-new-directory` in the same file system.
101124

102125
```azurecli
103-
az storage blob directory move -c my-file-system -d my-new-directory -s my-directory --account-name mystorageaccount
126+
az storage fs directory move -n my-directory -f my-file-system --new-directory "my-file-system/my-new-directory" --account-name mystorageaccount --auth-mode login
127+
```
128+
129+
This example moves a directory to a file system named `my-second-file-system`.
130+
131+
```azurecli
132+
az storage fs directory move -n my-directory -f my-file-system --new-directory "my-second-file-system/my-new-directory" --account-name mystorageaccount --auth-mode login
104133
```
105134

106135
## Delete a directory
107136

108-
Delete a directory by using the `az storage blob directory delete` command.
137+
Delete a directory by using the `az storage fs directory delete` command.
109138

110139
This example deletes a directory named `my-directory`.
111140

112141
```azurecli
113-
az storage blob directory delete -c my-file-system -d my-directory --account-name mystorageaccount
142+
az storage fs directory delete -n my-directory -f my-file-system --account-name mystorageaccount --auth-mode login
114143
```
115144

116145
## Check if a directory exists
117146

118-
Determine if a specific directory exists in the file system by using the `az storage blob directory exist` command.
147+
Determine if a specific directory exists in the file system by using the `az storage fs directory exists` command.
119148

120149
This example reveals whether a directory named `my-directory` exists in the `my-file-system` file system.
121150

122151
```azurecli
123-
az storage blob directory exists -c my-file-system -d my-directory --account-name mystorageaccount
152+
az storage fs directory exists -n my-directory -f my-file-system --account-name mystorageaccount --auth-mode login
124153
```
125154

126155
## Download from a directory
127156

128-
Download a file from a directory by using the `az storage blob directory download` command.
157+
Download a file from a directory by using the `az storage fs file download` command.
129158

130159
This example downloads a file named `upload.txt` from a directory named `my-directory`.
131160

132161
```azurecli
133-
az storage blob directory download -c my-file-system --account-name mystorageaccount -s "my-directory/upload.txt" -d "C:\mylocalfolder\download.txt"
134-
```
135-
136-
This example downloads an entire directory.
137-
138-
```azurecli
139-
az storage blob directory download -c my-file-system --account-name mystorageaccount -s "my-directory/" -d "C:\mylocalfolder" --recursive
162+
az storage fs file download -p my-directory/upload.txt -f my-file-system -d "C:\myFolder\download.txt" --account-name mystorageaccount --auth-mode login
140163
```
141164

142165
## List directory contents
143166

144-
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.
145168

146169
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`.
147170

148171
```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
150173
```
151174

152175
## Upload a file to a directory
153176

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.
155178

156179
This example uploads a file named `upload.txt` to a directory named `my-directory`.
157180

158181
```azurecli
159-
az storage blob directory upload -c my-file-system --account-name mystorageaccount -s "C:\mylocaldirectory\upload.txt" -d my-directory
160-
```
161-
162-
This example uploads an entire directory.
163-
164-
```azurecli
165-
az storage blob directory upload -c my-file-system --account-name mystorageaccount -s "C:\mylocaldirectory\" -d my-directory --recursive
182+
az storage fs file upload -s "C:\myFolder\upload.txt" -p my-directory/upload.txt -f my-file-system --account-name mystorageaccount --auth-mode login
166183
```
167184

168185
## Show file properties
169186

170-
You can print the properties of a file to the console by using the `az storage blob show` command.
187+
You can print the properties of a file to the console by using the `az storage fs file show` command.
171188

172189
```azurecli
173-
az storage blob show -c my-file-system -b my-file.txt --account-name mystorageaccount
190+
az storage fs file show -p my-file.txt -f my-file-system --account-name mystorageaccount --auth-mode login
174191
```
175192

176193
## Rename or move a file
177194

178-
Rename or move a file by using the `az storage blob move` command.
195+
Rename or move a file by using the `az storage fs file move` command.
179196

180197
This example renames a file from the name `my-file.txt` to the name `my-file-renamed.txt`.
181198

182199
```azurecli
183-
az storage blob move -c my-file-system -d my-file-renamed.txt -s my-file.txt --account-name mystorageaccount
200+
az storage fs file move -p my-file.txt -f my-file-system --new-path my-file-system/my-file-renamed.txt --account-name mystorageaccount --auth-mode login
184201
```
185202

186203
## Delete a file
187204

188-
Delete a file by using the `az storage blob delete` command.
205+
Delete a file by using the `az storage fs file delete` command.
189206

190207
This example deletes a file named `my-file.txt`
191208

192209
```azurecli
193-
az storage blob delete -c my-file-system -b my-file.txt --account-name mystorageaccount
210+
az storage fs file delete -p my-directory/my-file.txt -f my-file-system --account-name mystorageaccount --auth-mode login
194211
```
195212

196213
## Manage permissions
@@ -200,22 +217,22 @@ You can get, set, and update access permissions of directories and files.
200217
> [!NOTE]
201218
> 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).
202219
203-
### Get directory and file permissions
220+
### Get an ACL
204221

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.
206223

207224
This example gets the ACL of a directory, and then prints the ACL to the console.
208225

209226
```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
211228
```
212229

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.
214231

215232
This example gets the ACL of a file and then prints the ACL to the console.
216233

217234
```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
219236
```
220237

221238
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.
224241

225242
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).
226243

227-
### Set directory and file permissions
244+
### Set an ACL
228245

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**.
230247

231248
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.
232249

233250
```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
235252
```
236253

237254
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.
238255

239256
```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
241258
```
242259

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**.
244261

245262
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.
246263

247264
```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
249266
```
267+
250268
The following image shows the output after setting the ACL of a file.
251269

252270
![Get ACL output](./media/data-lake-storage-directory-file-acl-cli/set-acl-file.png)
253271

254272
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).
255273

256-
### Update directory and file permissions
274+
### Update an ACL
257275

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.
259277

260278
Update the ACL of a directory or file by setting the `-permissions` parameter to the short form of an ACL.
261279

262280
This example updates the ACL of a **directory**.
263281

264282
```azurecli
265-
az storage blob directory access update --permissions "rwxrwxrwx" -d my-directory -c my-file-system --account-name mystorageaccount
283+
az storage fs access set --permissions rwxrwxrwx -p my-directory -f my-file-system --account-name mystorageaccount --auth-mode login
266284
```
267285

268286
This example updates the ACL of a **file**.
269287

270288
```azurecli
271-
az storage blob access update --permissions "rwxrwxrwx" -b my-directory/upload.txt -c my-file-system --account-name mystorageaccount
289+
az storage fs access set --permissions rwxrwxrwx -p my-directory/upload.txt -f my-file-system --account-name mystorageaccount --auth-mode login
272290
```
273291

274292
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.
275293

276294
This example changes the owner of a directory.
277295

278296
```azurecli
279-
az storage blob directory access update --owner xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -d my-directory -c my-file-system --account-name mystorageaccount
297+
az storage fs access set --owner xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -p my-directory -f my-file-system --account-name mystorageaccount --auth-mode login
280298
```
281299

282300
This example changes the owner of a file.
283301

284302
```azurecli
285-
az storage blob access update --owner xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -b my-directory/upload.txt -c my-file-system --account-name mystorageaccount
286-
```
287-
## Manage user-defined metadata
288-
289-
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.
292-
293-
```azurecli
294-
az storage blob directory metadata update --metadata tag1=value1 tag2=value2 -c my-file-system -d my-directory --account-name mystorageaccount
295-
```
296-
297-
This example shows all user-defined metadata for directory named `my-directory`.
298-
299-
```azurecli
300-
az storage blob directory metadata show -c my-file-system -d my-directory --account-name mystorageaccount
303+
az storage fs access set --owner xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -p my-directory/upload.txt -f my-file-system --account-name mystorageaccount --auth-mode login
301304
```
302305

303306
## See also
304307

305-
* [Sample](https://github.com/Azure/azure-cli-extensions/tree/master/src/storage-preview)
306308
* [Gen1 to Gen2 mapping](https://github.com/Azure/azure-cli-extensions/tree/master/src/storage-preview#mapping-from-adls-gen1-to-adls-gen2)
307309
* [Give feedback](https://github.com/Azure/azure-cli-extensions/issues)
308310
* [Known issues](data-lake-storage-known-issues.md#api-scope-data-lake-client-library)
309-
* [Source code](https://github.com/Azure/azure-cli-extensions/tree/master/src)
311+
310312

0 commit comments

Comments
 (0)