Set-AzureStorageFileContent

Uploads the contents of a file.

Warning

The AzureRM PowerShell module has been officially deprecated as of February 29, 2024. Users are advised to migrate from AzureRM to the Az PowerShell module to ensure continued support and updates.

Although the AzureRM module may still function, it's no longer maintained or supported, placing any continued use at the user's discretion and risk. Please refer to our migration resources for guidance on transitioning to the Az module.

Syntax

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>]

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.

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:Nullable<T>[Int32]
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-AzureStorageContext 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-AzureStorageDirectory cmdlet. You can also use the Get-AzureStorageFile cmdlet to obtain a directory.

Type:CloudFileDirectory
Position:0
Default value:None
Required:True
Accept pipeline input:True
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

-ServerTimeoutPerRequest

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

Type:Nullable<T>[Int32]
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-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
Required:True
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

Parameters: Share (ByValue)

CloudFileDirectory

Parameters: Directory (ByValue)

String

IStorageContext

Outputs

CloudFile