Integrate Azure Powershell result into Azure workbook

William Li 0 Reputation points

I want to grab the PITR and longTermRetentionWeeks for all the sql databases in azure and display this along with some other basic values in azure workbook(for example subscription name, resource group name, db name, PITR, etc).

Seems these 2 values are not supported in resource graph query, I can get these through azure powershell(using


), but seems Azure powershell is not supported in azure workbooks.

Any way I can achieve this?

Azure SQL Database
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,321 questions
{count} votes

2 answers

Sort by: Most helpful
  1. AirGordon 7,030 Reputation points

    You could use the Search-AzGraph cmdlet to access the Resource Graph query results from PowerShell. This would give you the ability to either augment the query with the results from Get-AzSqlDatabaseBackupShortTermRetentionPolicy, or to use the results from the query when calling the Get-AzSqlDatabaseBackupShortTermRetentionPolicy cmdlet.

    Executing the PowerShell could then be done locally, from an Azure Automation Account Runbook, or another service capable of running PowerShell.

  2. Limitless Technology 44,116 Reputation points

    Hello there,

    When a runbook function writes to the output stream, the output is passed back to the runbook. If the runbook assigns that output to a variable, the output is not written to the output stream. Writing to any other streams from within the function writes to the corresponding stream for the runbook.

    Azure Automation works with each of these streams differently. You should follow best practices for using the streams when you're creating a runbook.

    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer--