-AzStorageBlobContent' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Kishan Bhise 0 Reputation points
2023-09-13T09:34:02.22+00:00
Im Trying to Store the CSV file generated in Azure Powershell Runbook to Azure blob Storage.
 But I'm Getting below Error :
Set-AzStorageBlobContent' is not recognized as a
name of a cmdlet, function, script file, or executable
program. Check the spelling of the name, or if a path was
included, verify that the path is correct and try again.here is the script I'm trying to Run 


Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,234 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,444 questions
{count} votes

1 answer

Sort by: Most helpful
  1. tbgangav-MSFT 10,426 Reputation points
    2023-09-13T11:49:42.9+00:00

    Hi @Kishan Bhise ,

    Save the content generated in runbook to a CSV file in temp location as shown in below command. Note that below command has assumption of storing content in $report variable and then exporting it to CSV file.

    $report | Export-CSV ($env:TEMP+"xxxxxxxxxxxx.csv") -Notype
    

    Then, upload csv file storage account as shown in below command.

    $Context = New-AzStorageContext -StorageAccountName "storagename" -StorageAccountKey "storagekey" 
    Set-AzStorageBlobContent -Context $Context -Container "container1" -File ($env:TEMP+"xxxxxxxxxxxx.csv") -Blob "xxxxxxxxxxxx.csv" -Force 
    

    Note: For the above commands to work in a runbook, make sure the cmdlets related modules are imported as explained here.

    Let me know if you have any further questions.

    Reference:

    https://learn.microsoft.com/en-us/answers/questions/1189680/

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.