Set-AzStorageFileContent

Uploads the contents of a file.

Syntax

Set-AzStorageFileContent
   [-ShareName] <String>
   [-Source] <String>
   [[-Path] <String>]
   [-PassThru]
   [-Force]
   [-AsJob]
   [-DisAllowTrailingDot]
   [-Context <IStorageContext>]
   [-ServerTimeoutPerRequest <Int32>]
   [-ClientTimeoutPerRequest <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [-ConcurrentTaskCount <Int32>]
   [-WhatIf]
   [-Confirm]
   [-PreserveSMBAttribute]
   [<CommonParameters>]
Set-AzStorageFileContent
   [-Share] <CloudFileShare>
   [-ShareClient <ShareClient>]
   [-Source] <String>
   [[-Path] <String>]
   [-PassThru]
   [-Force]
   [-AsJob]
   [-Context <IStorageContext>]
   [-ServerTimeoutPerRequest <Int32>]
   [-ClientTimeoutPerRequest <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [-ConcurrentTaskCount <Int32>]
   [-WhatIf]
   [-Confirm]
   [-PreserveSMBAttribute]
   [<CommonParameters>]
Set-AzStorageFileContent
   [-Directory] <CloudFileDirectory>
   [-ShareDirectoryClient <ShareDirectoryClient>]
   [-Source] <String>
   [[-Path] <String>]
   [-PassThru]
   [-Force]
   [-AsJob]
   [-Context <IStorageContext>]
   [-ServerTimeoutPerRequest <Int32>]
   [-ClientTimeoutPerRequest <Int32>]
   [-DefaultProfile <IAzureContextContainer>]
   [-ConcurrentTaskCount <Int32>]
   [-WhatIf]
   [-Confirm]
   [-PreserveSMBAttribute]
   [<CommonParameters>]

Description

The Set-AzStorageFileContent cmdlet uploads the contents of a file to a file on a specified share.

Examples

Example 1: Upload a file in the current folder

Set-AzStorageFileContent -ShareName "ContosoShare06" -Source "DataFile37" -Path "ContosoWorkingFolder/CurrentDataFile"

This command uploads a file that is named DataFile37 in the current folder as a file that is named CurrentDataFile in the folder named ContosoWorkingFolder.

Example 2: Upload all the files in the current folder

$CurrentFolder = (Get-Item .).FullName
$Container = Get-AzStorageShare -Name "ContosoShare06"
Get-ChildItem -Recurse | Where-Object { $_.GetType().Name -eq "FileInfo"} | ForEach-Object {
    $path=$_.FullName.Substring($Currentfolder.Length+1).Replace("\","/")
    Set-AzStorageFileContent -Share $Container -Source $_.FullName -Path $path -Force
}

This example uses several common Windows PowerShell cmdlets and the current cmdlet to upload all files from the current folder to the root folder of container ContosoShare06. The first command gets the name of the current folder and stores it in the $CurrentFolder variable. The second command uses the Get-AzStorageShare cmdlet to get the file share named ContosoShare06, and then stores it in the $Container variable. The final command gets the contents of the current folder and passes each one to the Where-Object cmdlet by using the pipeline operator. That cmdlet filters out objects that are not files, and then passes the files to the ForEach-Object cmdlet. That cmdlet runs a script block for each file that creates the appropriate path for it and then uses the current cmdlet to upload the file. The result has the same name and same relative position with regard to the other files that this example uploads. For more information about script blocks, type Get-Help about_Script_Blocks.

Example 3: Upload a local file to an Azure file, and perserve the local File SMB properties (File Attributtes, File Creation Time, File Last Write Time) in the Azure file.

Set-AzStorageFileContent -Source $localFilePath -ShareName sample -Path "dir1/file1" -PreserveSMBAttribute

This example uploads a local file to an Azure file, and perserves the local File SMB properties (File Attributtes, File Creation Time, File Last Write Time) in the Azure file.

Parameters

-AsJob

Run cmdlet in the background.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ClientTimeoutPerRequest

Specifies the client-side time-out interval, in seconds, for one service request. If the previous call fails in the specified interval, this cmdlet retries the request. If this cmdlet does not receive a successful response before the interval elapses, this cmdlet returns an error.

Type:Nullable<T>[Int32]
Aliases:ClientTimeoutPerRequestInSeconds
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ConcurrentTaskCount

Specifies the maximum concurrent network calls. You can use this parameter to limit the concurrency to throttle local CPU and bandwidth usage by specifying the maximum number of concurrent network calls. The specified value is an absolute count and is not multiplied by the core count. This parameter can help reduce network connection problems in low bandwidth environments, such as 100 kilobits per second. The default value is 10.

Type:Nullable<T>[Int32]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Context

Specifies an Azure storage context. To obtain a storage context, use the New-AzStorageContext cmdlet.

Type:IStorageContext
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:IAzureContextContainer
Aliases:AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Directory

Specifies a folder as a CloudFileDirectory object. This cmdlet uploads the file to the folder that this parameter specifies. To obtain a directory, use the New-AzStorageDirectory cmdlet. You can also use the Get-AzStorageFile cmdlet to obtain a directory.

Type:CloudFileDirectory
Aliases:CloudFileDirectory
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-DisAllowTrailingDot

Disallow trailing dot (.) to suffix directory and file names.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Force

Indicates that this cmdlet overwrites an existing Azure storage file.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-PassThru

Indicates that this cmdlet returns the AzureStorageFile object that it creates or uploads.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Path

Specifies the path of a file or folder. This cmdlet uploads contents to the file that this parameter specifies, or to a file in the folder that this parameter specifies. If you specify a folder, this cmdlet creates a file that has the same name as the source file. If you specify a path of a file that does not exist, this cmdlet creates that file and saves the contents to that file. If you specify a file that already exists, and you specify the Force parameter, this cmdlet overwrites the contents of the file. If you specify a file that already exists and you do not specify Force, this cmdlet makes no change, and returns an error. If you specify a path of a folder that does not exist, this cmdlet makes no change, and returns an error.

Type:String
Position:2
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-PreserveSMBAttribute

Keep the source File SMB properties (File Attributtes, File Creation Time, File Last Write Time) in destination File. This parameter is only available on Windows.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ServerTimeoutPerRequest

Specifies the length of the time-out period for the server part of a request.

Type:Nullable<T>[Int32]
Aliases:ServerTimeoutPerRequestInSeconds
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Share

Specifies a CloudFileShare object. This cmdlet uploads to a file in the file share this parameter specifies. To obtain a CloudFileShare object, use the Get-AzStorageShare cmdlet. This object contains the storage context. If you specify this parameter, do not specify the Context parameter.

Type:CloudFileShare
Aliases:CloudFileShare
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ShareClient

ShareClient object indicated the share where the file would be uploaded to.

Type:ShareClient
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ShareDirectoryClient

CloudFileDirectory object indicated the cloud directory where the file would be uploaded.

Type:ShareDirectoryClient
Position:Named
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-ShareName

Specifies the name of the file share. This cmdlet uploads to a file in the file share this parameter specifies.

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Source

Specifies the source file that this cmdlet uploads. If you specify a file that does not exist, this cmdlet returns an error.

Type:String
Aliases:FullName
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

CloudFileShare

CloudFileDirectory

String

IStorageContext

Outputs

AzureStorageFile