Invoke D365AzureStorageUpload - FH-Inway/d365fo.tools GitHub Wiki
Upload a file to Azure
Invoke-D365AzureStorageUpload [-AccountId <String>] [-AccessToken <String>] [-SAS <String>]
[-Container <String>] -Filepath <String> [-ContentType <String>] [-Force] [-DeleteOnUpload] [-EnableException]
[<CommonParameters>]
Invoke-D365AzureStorageUpload [-AccountId <String>] [-AccessToken <String>] [-SAS <String>]
[-Container <String>] -Filepath <String> [-ContentType <String>] [-Force] [-DeleteOnUpload] [-EnableException]
[<CommonParameters>]
Upload any file to an Azure Storage Account
Invoke-D365AzureStorageUpload -AccountId "miscfiles" -AccessToken "xx508xx63817x752xx74004x30705xx92x58349x5x78f5xx34xxxxx51" -Container "backupfiles" -Filepath "c:\temp\bacpac\UAT_20180701.bacpac" -DeleteOnUpload
This will upload the "c:\temp\bacpac\UAT_20180701.bacpac" up to the "backupfiles" container, inside the "miscfiles" Azure Storage Account that is access with the "xx508xx63817x752xx74004x30705xx92x58349x5x78f5xx34xxxxx51" token. After upload the local file will be deleted.
$AzureParams = Get-D365ActiveAzureStorageConfig
PS C:\> New-D365Bacpac | Invoke-D365AzureStorageUpload @AzureParams
This will get the current Azure Storage Account configuration details and use them as parameters to upload the file to an Azure Storage Account.
New-D365Bacpac | Invoke-D365AzureStorageUpload
This will generate a new bacpac file using the "New-D365Bacpac" cmdlet. The file will be uploaded to an Azure Storage Account using the "Invoke-D365AzureStorageUpload" cmdlet. This will use the default parameter values that are based on the configuration stored inside "Get-D365ActiveAzureStorageConfig" for the "Invoke-D365AzureStorageUpload" cmdlet.
Invoke-D365AzureStorageUpload -AccountId "miscfiles" -SAS "sv2018-03-28&siunlisted&src&sigAUOpdsfpoWE976ASDhfjkasdf(5678sdfhk" -Container "backupfiles" -Filepath "c:\temp\bacpac\UAT_20180701.bacpac" -DeleteOnUpload
This will upload the "c:\temp\bacpac\UAT_20180701.bacpac" up to the "backupfiles" container, inside the "miscfiles" Azure Storage Account. A SAS key is used to gain access to the container and uploading the file to it.
Storage Account Name / Storage Account Id where you want to store the file
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: $Script:AzureStorageAccountId
Accept pipeline input: False
Accept wildcard characters: False
The token that has the needed permissions for the upload action
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: $Script:AzureStorageAccessToken
Accept pipeline input: False
Accept wildcard characters: False
The SAS key that you have created for the storage account or blob container
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: $Script:AzureStorageSAS
Accept pipeline input: False
Accept wildcard characters: False
Name of the blob container inside the storage account you want to store the file
Type: String
Parameter Sets: (All)
Aliases: Blobname, Blob
Required: False
Position: Named
Default value: $Script:AzureStorageContainer
Accept pipeline input: False
Accept wildcard characters: False
Path to the file you want to upload
Type: String
Parameter Sets: Default
Aliases: Path, File
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
Type: String
Parameter Sets: Pipeline
Aliases: Path, File
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
Media type of the file that is going to be uploaded
The value will be used for the blob property "Content Type". If the parameter is left empty, the commandlet will try to automatically determined the value based on the file's extension. If the parameter is left empty and the value cannot be automatically be determined, Azure storage will automatically assign "application/octet-stream" as the content type. Valid media type values can be found here: https://www.iana.org/assignments/media-types/media-types.xhtml
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Instruct the cmdlet to overwrite the file in the container if it already exists
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Switch to tell the cmdlet if you want the local file to be deleted after the upload completes
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This parameters disables user-friendly warnings and enables the throwing of exceptions This is less user friendly, but allows catching exceptions in calling scripts
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Tags: Azure, Azure Storage, Config, Configuration, Token, Blob, File, Files, Bacpac, Container
Author: Mötz Jensen (@Splaxi)
The cmdlet supports piping and can be used in advanced scenarios. See more on github and the wiki pages.