你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Set-AzureStorageFileContent
上传文件的内容。
警告
截至 2024 年 2 月 29 日,AzureRM PowerShell 模块已正式弃用。 为了确保持续获得支持和更新,建议用户从 AzureRM 迁移到 Az PowerShell 模块。
尽管 AzureRM 模块仍可能正常运行,但它不再维护或受支持,但会根据用户的自由裁量权和风险继续使用任何继续使用模块。 有关过渡到 Az 模块的指导,请参阅我们的迁移资源。
语法
Set-AzureStorageFileContent
[-ShareName] <String>
[-Source] <String>
[[-Path] <String>]
[-PassThru]
[-Force]
[-Context <IStorageContext>]
[-ServerTimeoutPerRequest <Int32>]
[-ClientTimeoutPerRequest <Int32>]
[-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzureStorageFileContent
[-Share] <CloudFileShare>
[-Source] <String>
[[-Path] <String>]
[-PassThru]
[-Force]
[-ServerTimeoutPerRequest <Int32>]
[-ClientTimeoutPerRequest <Int32>]
[-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Set-AzureStorageFileContent
[-Directory] <CloudFileDirectory>
[-Source] <String>
[[-Path] <String>]
[-PassThru]
[-Force]
[-ServerTimeoutPerRequest <Int32>]
[-ClientTimeoutPerRequest <Int32>]
[-DefaultProfile <IAzureContextContainer>]
[-ConcurrentTaskCount <Int32>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
Set-Azure存储FileContent cmdlet 将文件的内容上传到指定共享上的文件。
示例
示例 1:上传当前文件夹中的文件
PS C:\>Set-AzureStorageFileContent -ShareName "ContosoShare06" -Source "DataFile37" -Path "ContosoWorkingFolder/CurrentDataFile"
此命令将当前文件夹中名为 DataFile37 的文件作为名为 ContosoWorkingFolder 文件夹中的 CurrentDataFile 的文件上传。
示例 2:上传当前文件夹中的所有文件
PS C:\>$CurrentFolder = (Get-Item .).FullName
PS C:\> $Container = Get-AzureStorageShare -Name "ContosoShare06"
PS C:\> Get-ChildItem -Recurse | Where-Object { $_.GetType().Name -eq "FileInfo"} | ForEach-Object {
$path=$_.FullName.Substring($Currentfolder.Length+1).Replace("\","/")
Set-AzureStorageFileContent -Share $Container -Source $_.FullName -Path $path -Force
}
此示例使用多个常见的 Windows PowerShell cmdlet 和当前 cmdlet 将当前文件夹中的所有文件上传到容器 ContosoShare06 的根文件夹。
第一个命令获取当前文件夹的名称,并将其存储在$CurrentFolder变量中。
第二个命令使用 Get-Azure存储Share cmdlet 获取名为 ContosoShare06 的文件共享,然后将其存储在$Container变量中。
最后一个命令获取当前文件夹的内容,并使用管道运算符将每个内容传递给 Where-Object cmdlet。
该 cmdlet 筛选出不是文件的对象,然后将文件传递给 ForEach-Object cmdlet。
该 cmdlet 为每个文件运行脚本块,该文件创建相应的路径,然后使用当前 cmdlet 上传文件。
结果与此示例上传的其他文件具有相同的名称和相对位置。
有关脚本块的详细信息,请键入 Get-Help about_Script_Blocks
。
参数
-ClientTimeoutPerRequest
指定一个服务请求的客户端超时间隔(以秒为单位)。 如果上一次调用在指定的时间间隔内失败,则此 cmdlet 将重试请求。 如果此 cmdlet 在间隔过前未收到成功的响应,则此 cmdlet 将返回错误。
类型: | Nullable<T>[Int32] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ConcurrentTaskCount
指定最大并发网络调用数。 可以使用此参数通过指定并发网络调用的最大数目来限制本地 CPU 和带宽使用量的并发性。 指定的值是绝对计数,不乘以核心计数。 此参数可帮助减少低带宽环境中的网络连接问题,例如每秒 100 千比特。 默认值为 10。
类型: | Nullable<T>[Int32] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Confirm
提示你在运行 cmdlet 之前进行确认。
类型: | SwitchParameter |
别名: | cf |
Position: | Named |
默认值: | False |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Context
指定 Azure 存储上下文。 若要获取存储上下文,请使用 New-Azure存储Context cmdlet。
类型: | IStorageContext |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | True |
接受通配符: | False |
-DefaultProfile
用于与 Azure 通信的凭据、帐户、租户和订阅。
类型: | IAzureContextContainer |
别名: | AzureRmContext, AzureCredential |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Directory
将文件夹指定为 CloudFileDirectory 对象。 此 cmdlet 将文件上传到此参数指定的文件夹。 若要获取目录,请使用 New-Azure存储Directory cmdlet。 还可以使用 Get-Azure存储File cmdlet 获取目录。
类型: | CloudFileDirectory |
Position: | 0 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-Force
指示此 cmdlet 覆盖现有的 Azure 存储文件。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-PassThru
指示此 cmdlet 返回它创建或上传的 Azure存储File 对象。
类型: | SwitchParameter |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Path
指定文件或文件夹的路径。 此 cmdlet 将内容上传到此参数指定的文件,或上传到此参数指定的文件夹中的文件。 如果指定文件夹,此 cmdlet 将创建与源文件同名的文件。 如果指定不存在的文件的路径,此 cmdlet 将创建该文件并将内容保存到该文件。 如果指定已存在的文件,并且指定 Force 参数,则此 cmdlet 将覆盖文件的内容。 如果指定已存在且未指定 Force 的文件,则此 cmdlet 不会进行更改,并返回错误。 如果指定不存在的文件夹的路径,则此 cmdlet 不会进行更改,并返回错误。
类型: | String |
Position: | 2 |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-ServerTimeoutPerRequest
指定请求的服务器部分超时期限的长度。
类型: | Nullable<T>[Int32] |
Position: | Named |
默认值: | None |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
-Share
指定 CloudFileShare 对象。 此 cmdlet 上传到文件共享中的文件,此参数指定。 若要获取 CloudFileShare 对象,请使用 Get-Azure存储Share cmdlet。 此对象包含存储上下文。 如果指定此参数,请不要指定 Context 参数。
类型: | CloudFileShare |
Position: | 0 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-ShareName
指定文件共享的名称。 此 cmdlet 上传到文件共享中的文件,此参数指定。
类型: | String |
Position: | 0 |
默认值: | None |
必需: | True |
接受管道输入: | False |
接受通配符: | False |
-Source
指定此 cmdlet 上传的源文件。 如果指定不存在的文件,则此 cmdlet 将返回错误。
类型: | String |
别名: | FullName |
Position: | 1 |
默认值: | None |
必需: | True |
接受管道输入: | True |
接受通配符: | False |
-WhatIf
显示运行该 cmdlet 时会发生什么情况。 cmdlet 未运行。
类型: | SwitchParameter |
别名: | wi |
Position: | Named |
默认值: | False |
必需: | False |
接受管道输入: | False |
接受通配符: | False |
输入
参数:共享(ByValue)
参数:目录(ByValue)