How to get the secrets from Azure Key Vault Using Azure SQL?

Govarthanan Venkatesan 66 Reputation points
2022-04-01T14:37:13.01+00:00

How to get the secrets from AKV using PowerShell script that needs to be automated in Stored Procedure in Azure SQL?

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
960 questions
Azure SQL Database
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,170 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,453 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. GeethaThatipatri-MSFT 23,617 Reputation points Microsoft Employee
    2022-04-01T15:00:55.797+00:00

    Hi @Govarthanan Venkatesan , Thanks for posting your question in the Microsoft Q&A forum.
    As we understand the ask here is you want to know how to get the secrets using PowerShell correct me if my understanding is wrong.

    You can find the PowerShell syntax in this document
    Get-AzureKeyVaultSecret -VaultName 'ABC' -Name 'test' Get the current version of a specific secret in to the name 'test'. the same you can output to a file
    | Out-File -FilePath .\secrets.txt

    Please let me know if the information is helpful
    Regards
    Geetha


  2. Newbie Jones 1,276 Reputation points
    2022-04-01T15:16:44.067+00:00

    Use the Azure Cmdlets. The other option is the REST interface.

    https://learn.microsoft.com/en-us/powershell/module/az.keyvault/get-azkeyvaultsecret?view=azps-7.3.2

    You need to ensure the (service) account running the PowerShell script has permissions to the key vault.

    0 comments No comments