0

I am trying to upload the files from GitHub repo to Azure file share and created shell script to run the AZ command like AZ login, create storage directory(if it not present) and finally Upload file to file share commands.

az login -u <username> -p <password> 
az storage directory create --name 'abc' --share-name 'xyz'
az storage file upload-batch --destination my store/myshare --source resources --account-name myaccount --account-key 00000000.

After ran above command, we are able to upload the JSON file into file share . But the file was uploaded as a string format.

Sample JSON:

{
  "source": "ABC"
} 

Getting the below error, when I was select file and edit the file in file share.

"{\n   \"source\":  \"ABC\" \n}"

I ran above shell script on ubuntu server.

If I am trying to upload the same file manually/ az storage file upload command in file share, file uploaded without any format issue.

Kindly help me.

CH BHARATH KUMAR
  • 111
  • 1
  • 11

1 Answers1

0

I tried in my environment and got the below results:

Initially, I tried with the same command and got the same results as in my file Share:

enter image description here

To upload the JSON files to Azure file share you need to add --content-type application/json to your command.

Command:

az login -u <username> -p <password> 
az storage directory create --name 'abc' --share-name 'xyz'
az storage file upload-batch --destination my store/myshare --source resources --account-name myaccount --account-key 00000000 --content-type application/json

Output:

uploading xxxxx\sample.json                                                                                                    
Finished[#############################################################]  100.0000%     
[
  "https://venkat123.file.core.windows.net/test/abc/sample.json"
]

enter image description here

Portal:

enter image description here

Reference:

az storage file | Microsoft Learn

Venkatesan
  • 3,748
  • 1
  • 3
  • 15