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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Tenant Migration Error

(6) ShareShare
ReportReport
Posted on by 85

Hello,

I am migrating my environment from one tenant to another. I have successfully submitted the request and it has been approved.

Now while trying to proceed with the usermapping.csv file I am getting the below error.

"WARNING: Can not upload the directory 'C:\Users\harsh\Desktop\usermapping.csv' to azure. If you want to upload directory, please use "ls -File -Recurse | Set-AzStorageBlobContent -Container containerName"

Any assistance to this would be appreciated.

Thank you

Categories:
I have the same question (0)
  • Ramesh Kumar Profile Picture
    7,527 Super User 2025 Season 2 on at

    Use PowerShell to Upload the File. Instead of uploading directly from the GUI, you can use PowerShell to upload the CSV file to Azure Blob Storage.

    Thanks, Ramesh

    If this was helpful, please check the "Does this answer your question?" box and mark it as verified.

     
  • Harsh 786 Profile Picture
    85 on at
     
    I am using the Window PowerShell only for the execution of the commands.
     
    All my previous commands were executed successfully, just facing problem here and could not move ahead due to this.
  • Suggested answer
    Daivat Vartak (v-9davar) Profile Picture
    7,835 Super User 2025 Season 2 on at
    Hello Harsh,
     

    The error message you're receiving is quite clear and points to the specific issue:

    "WARNING: Can not upload the directory 'C:\Users\harsh\Desktop\usermapping.csv' to azure. If you want to upload directory, please use "ls -File -Recurse | Set-AzStorageBlobContent -Container containerName"

    Explanation:

    • Set-AzStorageBlobContent: This PowerShell cmdlet is used to upload files to Azure Blob Storage.
    • Directory vs. File: The error message indicates that you're trying to upload a directory, but Set-AzStorageBlobContent is designed to upload files.
    • usermapping.csv: You're attempting to upload the usermapping.csv file, which is a single file, not a directory.
    • ls -File -Recurse | Set-AzStorageBlobContent -Container containerName: This is the correct syntax for uploading a directory and its contents recursively.

    •  

    Why You're Getting the Error (Likely):

    You're likely trying to upload the usermapping.csv file using a command that's intended for uploading directories. The command you're using is probably something like:

    Set-AzStorageBlobContent -Container "yourContainerName" -File "C:\Users\harsh\Desktop\usermapping.csv"

    Solution:

    The solution is to remove any directory-related parameters or syntax from your Set-AzStorageBlobContent command. You should be using the command as shown above, which is specifically for uploading a single file.

    Steps to Resolve:

    1. Verify Your Command: Carefully examine the PowerShell command you're using to upload the usermapping.csv file.

    2. Use Correct Syntax: Ensure you're using the correct syntax for uploading a single file:
      Set-AzStorageBlobContent -Container "yourContainerName" -File "C:\Users\harsh\Desktop\usermapping.csv"

      • Replace "yourContainerName" with the actual name of your Azure Blob Storage container. 

    3. Run the Command: Execute the corrected command in your PowerShell console.

     

    Additional Tips:

    • Azure Storage Context: Make sure you've correctly established an Azure Storage context using New-AzStorageContext before running Set-AzStorageBlobContent.
    • Container Existence: Verify that the specified container ("yourContainerName") exists in your Azure Storage account.
    • File Path: Double-check the file path to usermapping.csv to ensure it's correct.

    •  

    By using the correct syntax for uploading a single file, you should be able to resolve the error and successfully upload the usermapping.csv file for your tenant migration.

     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak
  • Harsh 786 Profile Picture
    85 on at
     
    Thank you for the response and further steps to execute. I did ran the command provided in the error message "ls -File -Recurse | Set-AzStorageBlobContent -Container containerName"  still no help with it. I get the below error message.
     
    Moreover here will I find the actual name of your Azure Blob Storage container as the command nor the document gives any direction or path
  • Suggested answer
    Daivat Vartak (v-9davar) Profile Picture
    7,835 Super User 2025 Season 2 on at
    Hello Harsh,
     

    You are encountering the error "Could not get the storage context" because the Set-AzStorageBlobContent cmdlet requires a storage account context to know which Azure Storage account and how to authenticate to it. The ls -File -Recurse command simply lists files and doesn't provide any storage account information.

    Here's a breakdown of how to resolve this and find your container name:

    Resolving the "Could Not Get the Storage Context" Error:

    You need to explicitly provide the storage context to the Set-AzStorageBlobContent cmdlet. There are a few ways to do this:

    1. Using New-AzStorageContext (Recommended for Explicit Control):

    This method involves creating a storage context object using your storage account name and either its key or a connection string.

    • Using Storage Account Key:
      $storageAccountName = "yourStorageAccountName"
      $storageAccountKey = "yourStorageAccountKey" # Be careful with your key!
      $context = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
      Get-ChildItem -File -Recurse | Set-AzStorageBlobContent -Container containerName -Context $context

    • Using Connection String:

      $connectionString = "DefaultEndpointsProtocol=https;AccountName=yourStorageAccountName;AccountKey=yourStorageAccountKey;EndpointSuffix=core.windows.net"
      $context = New-AzStorageContext -ConnectionString $connectionString
      Get-ChildItem -File -Recurse | Set-AzStorageBlobContent -Container containerName -Context $context

    Replace:

    • yourStorageAccountName with the actual name of your Azure Storage account.

    • yourStorageAccountKey with the access key of your Azure Storage account.

    • The connection string with your storage account's connection string (if using this method).

    •  

    2. Setting the Current Storage Account Context with Set-AzCurrentStorageAccount (Less Explicit, Use with Caution):

    This method sets a default storage account context for the current PowerShell session.

    $storageAccountName = "yourStorageAccountName"
    $storageAccountKey = "yourStorageAccountKey"
    Set-AzCurrentStorageAccount -Name $storageAccountName -Key $storageAccountKey
    Get-ChildItem -File -Recurse | Set-AzStorageBlobContent -Container containerName

    Replace:

    • yourStorageAccountName with the actual name of your Azure Storage account.

    • yourStorageAccountKey with the access key of your Azure Storage account.

    •  

    Important Security Note: Be very careful when handling your storage account keys. Avoid hardcoding them directly in scripts if possible, especially for production environments. Consider using Azure Key Vault for secure storage and retrieval of credentials.

    Finding the Actual Name of Your Azure Blob Storage Container:

    There are several ways to find the name of your Azure Blob Storage container:

    1. Using the Azure Portal (GUI):

    • Navigate to the Azure Portal (https://portal.azure.com/).

    • Find and open your Storage account.

    • In the left-hand menu, under "Data storage," click on Containers.

    • This will list all the Blob Storage containers within that storage account. The names are displayed directly in the list.

    •  

    2. Using Azure PowerShell (CLI):

    • List Containers in a Specific Storage Account:
      $storageAccountName = "yourStorageAccountName"
      $storageAccountKey = "yourStorageAccountKey"
      $context = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
      Get-AzStorageContainer -Context $context | Select-Object Name
       

      Replace:

      • yourStorageAccountName and $storageAccountKey with your storage account details. 

    • List Containers in the Current Subscription (if you've logged in with Connect-AzAccount):

      Get-AzStorageAccount | Get-AzStorageContainer | Select-Object Name

    3. Using Azure CLI:

    • List Containers in a Specific Storage Account:

      az storage container list --account-name <yourStorageAccountName> --account-key <yourStorageAccountKey> --query "[].name" -o tsv

      Replace:

      • <yourStorageAccountName> and <yourStorageAccountKey> with your storage account details.

      •  

    • List Containers in the Current Subscription (if you've logged in with az login):

      az storage container list --query "[].name" -o tsv


    •  

    In summary, to fix the error, you need to provide the storage context to Set-AzStorageBlobContent using either New-AzStorageContext with your storage account details or by setting the current context with Set-AzCurrentStorageAccount. To find your container name, use the Azure Portal or the Azure PowerShell/CLI commands to list the containers within your storage account.

    Remember to replace the placeholder values (like yourStorageAccountName, yourStorageAccountKey, and containerName) with your actual Azure Storage account and container details.

     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more. If you have further questions, please feel free to contact me.
     
    My response was crafted with AI assistance and tailored to provide detailed and actionable guidance for your Microsoft Dynamics 365 query.
     
    Regards,
    Daivat Vartak
  • Vahid Ghafarpour Profile Picture
    12,090 Super User 2025 Season 2 on at
     
    If any of the responses helped resolve your issue, please take a moment to mark the best answer. This helps others in the community quickly find solutions to similar problems.

    To do this, simply click the "Does this answer your question?" button on the most helpful response and like the helpful posts. If your issue is still unresolved, feel free to provide more details so the community can assist further!

    Thanks for being an active part of the Dynamics 365 Community! 😊
     
     

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 76

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans