你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
New-AzDataLakeGen2Item
在文件系统中创建文件或目录。
语法
New-AzDataLakeGen2Item
[-FileSystem] <String>
[-Path] <String>
-Source <String>
[-Umask <String>]
[-Permission <String>]
[-EncryptionContext <String>]
[-Property <Hashtable>]
[-Metadata <Hashtable>]
[-Force]
[-AsJob]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzDataLakeGen2Item
[-FileSystem] <String>
[-Path] <String>
[-Directory]
[-Umask <String>]
[-Permission <String>]
[-Property <Hashtable>]
[-Metadata <Hashtable>]
[-Force]
[-AsJob]
[-Context <IStorageContext>]
[-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
New-AzDataLakeGen2Item cmdlet 在 Azure 存储帐户的文件系统中创建文件或目录。 仅当为存储帐户启用了分层命名空间时,此 cmdlet 才有效。 可以使用“-EnableHierarchicalNamespace $true”运行“New-AzStorageAccount”cmdlet 来创建此类帐户。
示例
示例 1:创建具有指定权限、Umask、属性和元数据的目录
New-AzDataLakeGen2Item -FileSystem "testfilesystem" -Path "dir1/dir2/" -Directory -Permission rwxrwxrwT -Umask ---rw---- -Property @{"CacheControl" = "READ"; "ContentDisposition" = "True"} -Metadata @{"tag1" = "value1"; "tag2" = "value2" }
FileSystem Name: filesystem1
Path IsDirectory Length LastModified Permissions Owner Group
---- ----------- ------ ------------ ----------- ----- -----
dir1/dir2 True 2020-03-23 09:15:56Z rwx---rwT $superuser $superuser
此命令创建具有指定权限、Umask、属性和元数据的目录
示例 2:从本地源文件创建(上传)数据湖文件,cmdlet 在后台运行
$task = New-AzDataLakeGen2Item -FileSystem "testfilesystem" -Path "dir1/dir2/file1" -Source "c:\sourcefile.txt" -Force -asjob
$task | Wait-Job
$task.Output
FileSystem Name: filesystem1
Path IsDirectory Length LastModified Permissions Owner Group
---- ----------- ------ ------------ ----------- ----- -----
dir1/dir2/file1 False 14400000 2020-03-23 09:19:13Z rw-r----- $superuser $superuser
此命令从本地源文件创建数据湖文件,cmdlet 在后台运行。
示例 3:从本地源文件创建数据湖文件并设置其加密上下文
$file = New-AzDataLakeGen2Item -FileSystem "testfilesystem" -Path "dir1/dir2/file1" -Source "c:\sourcefile.txt" -EncryptionContext "encryptioncontext"
$file.Properties.EncryptionContext
encryptioncontext
此命令从本地源文件创建数据湖文件,并将其加密上下文值设置为“encryptioncontext”。
参数
-AsJob
在后台运行 cmdlet
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ConcurrentTaskCount
并发异步任务的总数。 默认值为 10。
类型: | Nullable<T>[Int32] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Confirm
在运行 cmdlet 之前,提示你进行确认。
类型: | SwitchParameter |
别名: | cf |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Context
Azure 存储上下文对象
类型: | IStorageContext |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-DefaultProfile
用于与 Azure 通信的凭据、帐户、租户和订阅。
类型: | IAzureContextContainer |
别名: | AzureRmContext, AzureCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Directory
指示此新项是目录而不是文件。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-EncryptionContext
文件的加密上下文。 加密上下文是在文件上存储时未加密的元数据。 此字段的主要应用程序是存储可用于为文件派生客户提供密钥的非加密数据。 不适用于目录。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-FileSystem
FileSystem 名称
类型: | String |
Position: | 0 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-Force
如果传递,则会在不出现任何提示的情况下创建新项
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Metadata
指定所创建的目录或文件的元数据。
类型: | Hashtable |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Path
应创建的指定文件系统中的路径。 可以是文件或目录,格式为“directory/file.txt”或“directory1/directory2/”
类型: | String |
Position: | 1 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-Permission
设置文件所有者、文件拥有组和其他文件的 POSIX 访问权限。 可以向每个类授予读取、写入或执行权限。 支持符号(rwxrw-rw-)。 粘性位也受支持,并且它由字母 t 或 T 表示在最终字符位置,具体取决于其他类别的执行位是分别设置还是未设置,缺少 t 或 T 表示未设置粘滞位。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Property
指定所创建的目录或文件的属性。 文件支持的属性包括:CacheControl、ContentDisposition、ContentEncoding、ContentLanguage、ContentMD5、ContentType。 目录支持的属性包括:CacheControl、ContentDisposition、ContentEncoding、ContentLanguage。
类型: | Hashtable |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Source
指定将上传到 Datalake Gen2 文件的本地源文件路径。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-Umask
创建新项和父目录没有默认 ACL 时,umask 将限制要创建的文件或目录的权限。 生成的权限由 p & ^u 提供,其中 p 是权限,你是 umask。 支持符号(rwxrw-rw-)。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-WhatIf
显示 cmdlet 运行时会发生什么情况。 cmdlet 未运行。
类型: | SwitchParameter |
别名: | wi |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |