0

we are writing the following command to copy the file from the Azure function app local to our file share i.e.; mounted in the VM:\

Command:

    Set-AzStorageFileContent -Source 'C:/home/site/wwwroot/HttpTrigger2/demo.tfvars' -ShareName "storage-fileshare" -Path "Demo/Test" -Context $destctx -Force -ContentEncoding "UTF-8"  #-Properties @{"ContentEncoding" = "UTF-8"}

 

The issue that we facing now is the Encoding of the file content is changing when it is being written in the file share.

The result that we are getting: "tfv_storage_account_name="sandeep"\r\ntfv_location_storage="Brazil"\r\ntfv_account_tier="Standard"\r\n

/n/r gets appended in our original file it was not there

We expect to file at file share like the below content

tfv_storage_account_name="sandeep" 
tfv_location_storage="Brazil"
tfv_account_tier="Standard"

In the command line, I tried to append the followings: 1.    -Properties @{"ContentEncoding" = "UTF-8"} 2.    -ContentEncoding "UTF-8" 3.    -Encoding UTF-8, etc.

Anyone faced this issue of why file content gets appended with /n/r etc?

Monish Khatri
  • 820
  • 1
  • 7
  • 24

1 Answers1

0

I have reproduced in my environment and I got expected results as below and I followed Microsoft-Document:

Firstly i have used below commands:

$destctx=New-AzStorageContext -StorageAccountName "name of storage acc" -StorageAccountKey "Storage acc key"
New-AzStorageDirectory -ShareName "File share name" -Path "Demo" -Context $destctx
Set-AzStorageFileContent -Source "C:\Users\Downloads\vars.tfvar" -ShareName "File Share name" -Path "Demo/Fest" -Context $destctx -Force 

Output:

Checked using cat Filenamecommand :

enter image description here

Then checked the same in portal:

enter image description here

RithwikBojja
  • 5,069
  • 2
  • 3
  • 7
  • Hello Rithwik, I tried the same but the result is not coming as desired. Just wanted to add on, I have the file in local of function app server and from there I am copying it to file share. The file share is mounted in an AzureVM. – SANDEEP KUMAR Mar 28 '23 at 07:58
  • Yeah I have done the same and got required output. – RithwikBojja Mar 28 '23 at 08:23