%3CLINGO-SUB%20id%3D%22lingo-sub-1992695%22%20slang%3D%22en-US%22%3ELogic%20app%20creates%20unreadable%20base64%20encoded%20files%20using%20HTTP%20action%20on%20Azure%20Blob%20Storage%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1992695%22%20slang%3D%22en-US%22%3E%3CP%3EWhen%20the%20logic%20app%20creates%20a%20file%26nbsp%3Busing%20HTTP%20action%20PUT%20method%20on%20Azure%20Blob%20Storage%2C%20the%20file%20cannot%20be%20read%20as%20it%20appears%20as%20corrupted%20when%20trying%20to%20open%20the%20file.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20main%20reason%20for%20this%20is%20that%20in%20order%20to%20avoid%20problems%20with%20special%20characters%2C%20Logic%20app%20uses%20Base64%20encoding%20to%20encode%20files%20while%20processing%2C%20as%20a%20result%20the%20created%20files%20are%20Base64%20encoded%20and%20in%20order%20for%20the%20files%20to%20be%20created%20correctly%20to%20Azure%20Blob%20Storage%2C%20it%20needs%20to%20be%20converted%20to%20binary.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20the%20following%20line%20of%20text%3A%3CBR%20%2F%3ETest%201234%20as%20Base64!%3CBR%20%2F%3Ewould%20instead%20appear%20as%3A%3CBR%20%2F%3EVGVzdCAxMjM0IGFzIEJhc2U2NCE%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20resolve%20this%2C%20use%20%3CSTRONG%3Ebase64toBinary()%3C%2FSTRONG%3E%20function%20when%20creating%20files%20on%20Azure%20Blob%20Storage%2C%20so%20we%20apply%20this%20function%20to%20the%20file%20content%20passed%20in%20the%20body%20field%20of%20the%20HTTP%20action.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20will%20need%20to%20switch%20to%20code%20view%20to%20apply%20this%20function%20manually%2C%20final%20HTTP%20body%20should%20look%20like%20the%20following%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CDIV%3E%3CSTRONG%3E%22body%22%3A%26nbsp%3B%22%40%7Bbase64ToBinary(%3C%2FSTRONG%3Eitems('For_each')%3F%5B'ContentBytes'%5D%3CSTRONG%3E)%7D%22%2C%3C%2FSTRONG%3E%3C%2FDIV%3E%0A%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1992695%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22AzureBlob.png%22%20style%3D%22width%3A%20399px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F241020i709A771915842E5C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20title%3D%22AzureBlob.png%22%20alt%3D%22AzureBlob.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3ELogic%20app%20creates%20unreadable%20base64%20encoded%20files%20using%20HTTP%20action%20on%20Azure%20Blob%20Storage%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1992695%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ELogic%20Apps%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

When the logic app creates a file using HTTP action PUT method on Azure Blob Storage, the file cannot be read as it appears as corrupted when trying to open the file.

 

The main reason for this is that in order to avoid problems with special characters, Logic app uses Base64 encoding to encode files while processing, as a result the created files are Base64 encoded and in order for the files to be created correctly to Azure Blob Storage, it needs to be converted to binary.

 

For example, the following line of text:
Test 1234 as Base64!
would instead appear as:
VGVzdCAxMjM0IGFzIEJhc2U2NCE

 

To resolve this, use base64toBinary() function when creating files on Azure Blob Storage, so we apply this function to the file content passed in the body field of the HTTP action.

 

You will need to switch to code view to apply this function manually, final HTTP body should look like the following:

 

"body": "@{base64ToBinary(items('For_each')?['ContentBytes'])}",