Set-​Azure​Storage​File​Content

Uploads the contents of a file.

Syntax

Set-AzureStorageFileContent
   [-ShareName] <String>
   [-Source] <String>
   [[-Path] <String>]
   [-ClientTimeoutPerRequest <Int32>]
   [-ConcurrentTaskCount <Int32>]
   [-Context <AzureStorageContext>]
   [-Force]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [-PassThru]
   [-PipelineVariable <String>]
   [-ServerTimeoutPerRequest <Int32>]
   [-Confirm]
   [-WhatIf]
   [<CommonParameters>]
Set-AzureStorageFileContent
   [-Directory] <CloudFileDirectory>
   [-Source] <String>
   [[-Path] <String>]
   [-ClientTimeoutPerRequest <Int32>]
   [-ConcurrentTaskCount <Int32>]
   [-Force]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [-PassThru]
   [-PipelineVariable <String>]
   [-ServerTimeoutPerRequest <Int32>]
   [-Confirm]
   [-WhatIf]
   [<CommonParameters>]
Set-AzureStorageFileContent
   [-Share] <CloudFileShare>
   [-Source] <String>
   [[-Path] <String>]
   [-ClientTimeoutPerRequest <Int32>]
   [-ConcurrentTaskCount <Int32>]
   [-Force]
   [-InformationAction <ActionPreference>]
   [-InformationVariable <String>]
   [-PassThru]
   [-PipelineVariable <String>]
   [-ServerTimeoutPerRequest <Int32>]
   [-Confirm]
   [-WhatIf]
   [<CommonParameters>]

Description

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

Examples

Example 1: Upload a file in the current folder

PS C:\>Set-AzureStorageFileContent -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

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
}

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

Required Parameters

-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-AzureStorageDirectory cmdlet. You can also use the Get-AzureStorageFile cmdlet to obtain a directory.

Type:CloudFileDirectory
Position:0
Default value:None
Accept pipeline input:True (ByValue)
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-AzureStorageShare cmdlet. This object contains the storage context. If you specify this parameter, do not specify the Context parameter.

Type:CloudFileShare
Position:0
Default value:None
Accept pipeline input:True (ByValue)
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
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
Accept pipeline input:True (ByPropertyName)
Accept wildcard characters:False

Optional Parameters

-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:Int32
Position:Named
Default value:None
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:Int32
Position:Named
Default value:None
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
Accept pipeline input:False
Accept wildcard characters:False
-Context

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

Type:AzureStorageContext
Position:Named
Default value:None
Accept pipeline input:True (ByPropertyName, ByValue)
Accept wildcard characters:False
-Force

Indicates that this cmdlet overwrites an existing Azure storage file.

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

Specifies how this cmdlet responds to an information event.The acceptable values for this parameter are:- Continue

  • Ignore
  • Inquire
  • SilentlyContinue
  • Stop
  • Suspend
Type:ActionPreference
Aliases:infa
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-InformationVariable

Specifies an information variable.

Type:String
Aliases:iv
Position:Named
Default value:None
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
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
Accept pipeline input:False
Accept wildcard characters:False
-PipelineVariable

Stores the value of the current pipeline element as a variable, for any named command as it flows through the pipeline.

Type:String
Aliases:pv
Position:Named
Default value:None
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:Int32
Position:Named
Default value:None
Accept pipeline input:False
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
Accept pipeline input:False
Accept wildcard characters:False