Hello @Raj D ,
Thanks for the question and using MS Q&A platform.
It sounds like you are trying to upload to ADLS Gen2 using powershell. However, the code you have shared only tries to create a new container. It does not show any commands for uploading.
New-AzDataLakeGen2Item -Context $storageContext -FileSystem MyContainer -Path MyDir/MyData.json -Source MyData.json -Force
New-AzDataLakeGen2Item -Context $storageContext -FileSystem $containerName -Path ($directory-name + "/" + $file-name) -Source $file-name -Force
Example code sourced from data-lake-storage-directory-file-acl-powershell: uploading a file
$localSrcFile = "upload.txt"
$filesystemName = "my-file-system"
$dirname = "my-directory/"
$destPath = $dirname + (Get-Item $localSrcFile).Name
New-AzDataLakeGen2Item -Context $ctx -FileSystem $filesystemName -Path $destPath -Source $localSrcFile -Force
Also see example from powershell reference
$task = New-AzDataLakeGen2Item -FileSystem "testfilesystem" -Path "dir1/dir2/file1" -Source "c:\sourcefile.txt" -Force -asjob
$task | Wait-Job
$task.Output
FileSystem Name: filesystem1
Path IsDirectory Length LastModified Permissions Owner Group
---- ----------- ------ ------------ ----------- ----- -----
dir1/dir2/file1 False 14400000 2020-03-23 09:19:13Z rw-r----- $superuser $superuser
With the missing command out of the way, there seems to be another issue you mentioned
I'm trying to run this powershell script in Azure automation runbook I tried storage account key & managed identity for access onto container and nothing seems to work.
You haven't mentioned what precisely went wrong, or any error messages. So I am uncertain whether you are facing an authentication issue, or a container creation issue, or you just got confused between uploading and creating container.
Please do let me if you have any queries.
Thanks
Martin
- Please don't forget to click on
or upvote
button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
- Want a reminder to come back and check responses? Here is how to subscribe to a notification
- If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators