Connect Azure Automation Account to Azure SQL using Managed Identity

Michel Sfeir 85 Reputation points
2025-02-19T09:56:47.0966667+00:00

Hello,

I'm trying to create a Runbook (Powershell) to connect to Azure SQL Database and then add an Entra ID user in that database. If there is way to do so in CLI commands it's fine by me. The problem is that we're always stuck at the DB connection step using UMI which is already a db owner in the Azure SQL

Thanks a lot for your support.

Best Regards,

Michel

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

Accepted answer
  1. Nandan Hegde 34,251 Reputation points MVP
    2025-02-19T14:25:47.1+00:00

    You can use the below command for Az automation to connect :

    Connect-AzAccount -Identity -SubscriptionName $SubscriptionNm
    

    And execute any powershell commands to database directly :

    ex:

        $Sourcedatabase = Get-AzSqlDatabase -ResourceGroupName $sourceRG -ServerName $sourceServernm -DatabaseName $sourcedbnm
    

0 additional answers

Sort by: Most helpful

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.