# Retrieve Key From Azure Key Vault

**URL:** <https://forum.ansible.com/t/retrieve-key-from-azure-key-vault/45010>\
**Category:** Get Help\
**Tags:** azure, aap\
**Created:** [December 18, 2025, 7:13pm UTC](https://forum.ansible.com/t/retrieve-key-from-azure-key-vault/45010 "2025-12-18T19:13:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![blockedprocess](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@blockedprocess](https://forum.ansible.com/u/blockedprocess)\
**Post date:** [December 18, 2025, 7:13pm UTC](https://forum.ansible.com/t/retrieve-key-from-azure-key-vault/45010/1 "2025-12-18T19:13:15Z")

</div>

I’m using Ansible Automation Platform 2.5 operator install on OpenShift. I want to be able to retrieve a private key stored in Azure Key Vault as a key to use as the private key for an ssh connection.

Is there a way to make this happen? All I can find is secret retrieval, and my attempts to store a key as a secret and retrieve into the SSH Private Key field of my Machine credential result in:

Error loading key “/runner/artifacts/2000/ssh\_key\_data”: invalid format

Password vi ssh with the same cred retrieved as a secret into the Password field works just fine.

---

<div class="post-metadata">

**Author:** ![dbrennand](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dbrennand/32/7830_2.png) [@dbrennand](https://forum.ansible.com/u/dbrennand)\
**Post date:** [December 19, 2025, 6:25pm UTC](https://forum.ansible.com/t/retrieve-key-from-azure-key-vault/45010/2 "2025-12-19T18:25:48Z")

</div>

Hi there @blockedprocess,

Welcome to the Ansible forum!

I’ve not configured this myself, but I think this page might have what you need? Or can at least help point you in the right direction.

> **[AWX/AAP - XWiki](https://wiki.helsinki.fi/xwiki/bin/view/SO/Security%20and%20Data%20Confidentiality/Secrets%20management/Azure%20Key%20Vault/AWXAAP/)**
>
> AWX/AAP

Specifically the heading **Retrieving Machine credentials from Azure Key Vault**.

---

<div class="post-metadata">

**Author:** ![blockedprocess](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@blockedprocess](https://forum.ansible.com/u/blockedprocess)\
**Post date:** [December 19, 2025, 7:14pm UTC](https://forum.ansible.com/t/retrieve-key-from-azure-key-vault/45010/3 "2025-12-19T19:14:21Z")

</div>

Hi, thanks for replying!

I actually figured this out. Using the az command to upload the key as a secret put it in the correct format that Ansible could read.

az login  
az keyvault secret set --vault-name “YourKeyVaultName” --name “YourSecretName” --file “~/path/to/id\_rsa\_private\_key\_file”

Once there, using a machine cred with the key button under SSH Private Key, I was able to specify the external vault and retrieve the private key as a secret that way, and it worked!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [January 18, 2026, 7:14pm UTC](https://forum.ansible.com/t/retrieve-key-from-azure-key-vault/45010/4 "2026-01-18T19:14:52Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
