Need help in Azure Automation Runbook PowerShell

Sania 21 Reputation points
2022-10-31T18:54:27.38+00:00

I am new to Azure Automation Runbook and want to know how Runbook works

  1. How we can use the file stored in Azure blob storage when using Runbook automation?
    As, I have a Power BI PBIX file stored in blob storage and I have a PS script which uses local path and uploads the file to Power BI Service when using it from Windows PowerShell but when I run the same script in Runbook it doesn't read the local path and ends up with error so what exactly to be used as the path to upload the files to Power BI Service using PowerShell Runbook Automation

Local Path of the file I am using to upload to Power BI Service
$pbixFilePath = "C:\Users\file\Sample.pbix"

What is the Path to use when running the same PS script in Runbook Automation?

  1. Where the output file is stored when we run Azure runbook?
    I saw somewhere where it says the file will be stored to $env:temp folder, how to locate to that? Is it in Azure portal or in our Local machine? Can you please tell me more about that temp folder
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,544 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,159 questions
{count} votes

Accepted answer
  1. AnuragSingh-MSFT 20,986 Reputation points
    2022-11-10T10:23:00.71+00:00

    Thank you @Sania for the additional details above.

    A basic understanding of Azure Automation runbook execution should help clarify this doubt. When runbooks are designed to authenticate and run against resources in Azure, they run in an Azure sandbox. Azure Automation assigns a worker to run each job during runbook execution in the sandbox. Please see this link for more details - Runbook execution environment These sandboxes are isolated environment with access to only some of the location/path/directories.

    The following section should help answer the question - ... which path I have to use if the PBIX file is stored in Azure storage container and how the PowerShell script can be created?

    The script snippet provided by Manu above would download the blob content in the same directory inside sandbox from where script is running. You can access this path inside the script using ".\" --> for example, if the blob that you are downloading is named testBlob, it will be available in location .\testBlob. (".\" stands for current directory).

    Therefore, the pbixFilePath can be initialized as $pbixFilePath = ".\Test.pbix"

    Another option is to use $env:temp as mentioned in the question. It is one of the environments variable available on local machine (on your workstation) which generally resolves to C:\Users\<username>\AppData\Local\Temp

    In Azure Automation sandbox environment, this variable resolves to C:\Users\Client\Temp

    Therefore, you could download the blob content using the following line:

     Get-AzStorageBlobContent -Blob $blob -Container $ContainerName -Context $Ctx -Destination $env:temp  #Destination parameter sets the target folder. By default it is local directory (.\)  
    

    In this case, you would initialize pbixFilePath as $pbixFilePath = $env:temp+"\Test.pbix"

    Either case is fine as long as the Automation limits are not exceeded.

    Hope this helps. Please let us know if you have any questions.


    Please 'Accept as answer' if it helped so that it can help others in the community looking for help on similar topics.

    1 person found this answer helpful.

2 additional answers

Sort by: Most helpful
  1. Manu Philip 17,021 Reputation points MVP
    2022-11-01T07:44:02.06+00:00

    Azure Automation Runbooks can't communicate with your local computer storage/files. You can use Hybrid Runbook Worker feature of Azure Automation to run runbooks on your computer with local files used

    ----------

    --please don't forget to upvote and Accept as answer if the reply is helpful--


  2. Kumar Tyagi, Praveen 0 Reputation points
    2023-04-26T08:52:45.4266667+00:00

    Hi, I've created runbook as default without creating any agent. Getting below warning, does that effect my run book

    "Azure Automation Agent-based User Hybrid Runbook Worker (Windows and Linux) will retire on 31 August 2024 and wouldn't be supported after that date. You must complete migrating existing Agent-based User Hybrid Runbook Workers to Extension-based Workers before 31 August 2024. Moreover, starting 1 October 2023, creating new Agent-based Hybrid Workers wouldn't be possible. Learn more."