Copy-AzureItem.ps1

function Copy-AzureItem
{
    <#
    .SYNOPSIS
        This function simplifies the process of uploading files to an Azure storage account. In order for this function to work you
        must have already logged into your Azure subscription with Login-AzureAccount. The file uploaded will be called the file
        name as the storage blob.
    .NOTES
        By: Adam Bertram
    .PARAMETER FilePath
        The local path of the file(s) you'd like to upload to an Azure storage account container.
     
    .PARAMETER ContainerName
        The name of the Azure storage account container the file will be placed in.
     
    .PARAMETER ResourceGroupName
        The name of the resource group the storage account is in.
     
    .PARAMETER StorageAccountName
        The name of the storage account the container that will hold the file is in.
    .LINK
        http://www.adamtheautomator.com/copy-azureitem-an-easy-way-to-copy-files-to-azure/
    #>

    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory,ValueFromPipelineByPropertyName)]
        [ValidateNotNullOrEmpty()]
        [ValidateScript({ Test-Path -Path $_ -PathType Leaf })]
        [Alias('FullName')]
        [string]$FilePath,
    
        [Parameter(Mandatory)]
        [ValidateNotNullOrEmpty()]
        [string]$ContainerName,
    
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [string]$ResourceGroupName = 'ResourceGroup',
    
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [string]$StorageAccountName = 'StorageAccount'
    )
    process
    {
        try
        {
            $saParams = @{
                'ResourceGroupName' = $ResourceGroupName
                'Name' = $StorageAccountName
            }
            
            $scParams = @{
                'Container' = $ContainerName
            }
            
            $bcParams = @{
                'File' = $FilePath
                'Blob' = ($FilePath | Split-Path -Leaf)
            }
            Get-AzureRmStorageAccount @saParams | Get-AzureStorageContainer @scParams | Set-AzureStorageBlobContent @bcParams
        }
        catch
        {
            Write-Error $_.Exception.Message
        }
    }
}