web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Upload Files to Azure ...
Power Apps
Suggested Answer

Upload Files to Azure File From Power Apps

(0) ShareShare
ReportReport
Posted on by

I created a Microsoft Power App to upload documents to Azure File (not blob). I use attachment control to collect the file, and then Power Automate flow to upload to Azure File. 

 

Here is the Power Automate flow: 

1) Power Apps (V2)

Text type input named "FileName"

File type input named "FileContent" 

2) Create File (Azure File Storage) 

Folder path established

File name: FileName

File content: FileContent

 

I added an Upload button with below code: 

SaveFileToAzureFile.Run("Test",First(Attachment.Attachments))

 

Clicking the Upload button does successfully add the file with proper name to Azure File with the name "Test". 

 

Here's the problem: The file gets to Azure File, but content is not openable. The files are only 1kb and open null. So it seems the File Content is not making its way. I'm assuming this is an intricacy with binary vs bas64.



I have tried JSON conversions:

ForAll(

Attachment.Attachments,
SaveFileToAzureFile.Run(
ThisRecord.Name,
{
Name: ThisRecord.Name,
ContentBytes: JSON(ThisRecord.Value, JSONFormat.IncludeBinaryData)
}))

I have tried sending .Value:
ForAll(
    Attachment.Attachments,
    SaveFileToAzureFile.Run(
        ThisRecord.Name,
        ThisRecord.Value
    ))

I have tried passing as a record:
ForAll(
Attachment.Attachments,
SaveFileToAzureFile.Run(
ThisRecord.Name,
{
name: ThisRecord.Name,
contentBytes: ThisRecord.Value
}))

And I have also tried base64 conversions in the flow:
base64ToBinary(triggerBody()?['FileContent']?['contentBytes'])

I have exhausted the help of AI and am now looking to real humans for the answer!
Screenshot 2026-0...
Screenshot 2026-0...

Your file is currently under scan for potential threats. Please wait while we review it for any viruses or malicious content.

I have the same question (0)
  • Suggested answer
    Gil0 Profile Picture
    128 on at
    Hello,
     
    I have dealt with a similar scenario and got this to work with a component that I created to convert any files to Base64 by manipulating an Image control inside of it, here is the YAML code:
     
    ComponentDefinitions:
      ConvertToBase64:
        DefinitionType: CanvasComponent
        CustomProperties:
          ToBase64:
            PropertyKind: Action
            DisplayName: ToBase64
            Description: A custom property
            ReturnType: Text
            Parameters:
              - FileData:
                  Description: FileData
                  DataType: Text
                  Default: ="Text"
        Properties:
          Height: =1
          ToBase64: |-
            =Set(varImageValue,FileData);
            Mid(
                JSON(Image2.Image, JSONFormat.IncludeBinaryData),
                Find(",", JSON(Image2.Image, JSONFormat.IncludeBinaryData)) + 1,
                Len(JSON(Image2.Image, JSONFormat.IncludeBinaryData)) - Find(",", JSON(Image2.Image, JSONFormat.IncludeBinaryData)) - 1
            )
          Width: =1
        Children:
          - Image2:
              Control: Image@2.2.3
              Properties:
                BorderColor: =RGBA(0, 18, 107, 1)
                Image: =varImageValue
                X: =40
                Y: =40
    
    I also created a component that uses the attachment control outside of a form control:
     
    ComponentDefinitions:
      FileAttachment_2:
        DefinitionType: CanvasComponent
        CustomProperties:
          Attachments:
            PropertyKind: Output
            DisplayName: Attachments
            Description: A custom property
            DataType: Record
          Border:
            PropertyKind: Input
            DisplayName: Border
            Description: A custom property
            DataType: Color
            Default: =Color.Transparent
          Items:
            PropertyKind: Input
            DisplayName: Items
            Description: A custom property
            DataType: Table
            Default: =
          MaxAttachmentSize:
            PropertyKind: Input
            DisplayName: Max Attachment Size
            Description: A custom property
            DataType: Number
            Default: =100
          MaximumAttachments:
            PropertyKind: Input
            DisplayName: Maximum Attachments
            Description: A custom property
            DataType: Number
            Default: =5
          NoAttachmentText:
            PropertyKind: Input
            DisplayName: No Attachment Text
            Description: A custom property
            DataType: Text
            Default: ="There is nothing attached."
          OnAddFile:
            PropertyKind: Input
            DisplayName: OnAddFile
            Description: A custom property
            DataType: Record
            Default: =
          Reset:
            PropertyKind: Input
            DisplayName: Reset
            Description: A custom property
            DataType: Boolean
            Default: =true
        Properties:
          Attachments: |-
            ={FileAttachment: FileAttachmentControl_1.Attachments}
          Height: =80
          OnReset: =Reset(FileAttachmentControl_1)
          Width: =200
        Children:
          - FileAttachmentControl_1:
              Control: Attachments@2.3.0
              Properties:
                BorderColor: =FileAttachment_2.Border
                Color: =RGBA(255, 255, 255, 1)
                DropTargetBackgroundColor: =RGBA(0, 0, 0, 0)
                DropTargetBorderStyle: =BorderStyle.None
                Fill: =RGBA(0, 0, 0, 0)
                Font: =Font.'Open Sans'
                Height: =80
                HoverFill: =RGBA(186, 202, 226, 1)
                ItemColor: =RGBA(255, 255, 255, 1)
                ItemFill: =RGBA(56, 96, 178, 1)
                ItemHoverFill: =RGBA(186, 202, 226, 1)
                Items: =FileAttachment_2.Items
                Items.Name: =SampleStringField
                Items.Value: =SampleStringField
                MaxAttachmentSize: =FileAttachment_2.MaxAttachmentSize
                MaxAttachments: =FileAttachment_2.MaximumAttachments
                NoAttachmentsText: =FileAttachment_2.NoAttachmentText
                OnAddFile: =FileAttachment_2.OnAddFile
                PaddingTop: =10
                PressedColor: =RGBA(255, 255, 255, 1)
                PressedFill: =RGBA(0, 18, 107, 1)
                Reset: =FileAttachment_2.Reset
                Size: =8
                TabIndex: =1
                Tooltip: =
                Width: =200
    
     
     
    Using these two components, I am then able to convert each attachment in the Attachment component with the ConvertToBase64 component within the button's OnSelect property and run the flow as such:
     
    //For each attachment, convert to base64 and store in a collection
    ForAll(
        AttachmentComponent.Attachments.FileAttachment As doc,
        Collect(
            colFilesToUpload,
            {
                FileName: doc.Name,
                FileContent:  ConvertToBase64.ToBase64(doc.Value),
                FolderPath: ""
            }
        )
    );
    
    //Send all attachments to flow
    Set(varUploadFile, 'CreateFile'.Run(JSON(colFilesToUpload, JSONFormat.IncludeBinaryData));
    
     
    Now in the Power Automate flow, the JSON output is received as text:
     
    Parse the JSON:
    Then, run an Apply to Each action for the Parse JSON Body:
     
    Add a Create File action in the Apply to Each and iterate through the following items from the Parse JSON Body:
    Here is the function for the File Content:
    base64ToBinary(items('Apply_to_each')?['FileContent'])
    Don't forget to let the users know that the upload was successful by returning a response from your flow:
    //Notify if upload was successful
    If( 
        !IsBlank(varUploadFile),
        Notify("Files uploaded successfully!", NotificationType.Success),
        Notify("Upload failed. Please try again.", NotificationType.Error)
    );
     
    If this response was helpful to you, please mark your post as resolved so that others may reference to it.
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard