how to get public key from certificate on azure automation - linux

I need to get SSH public key from the certificate which is store on azure portal and I have created workflow on azure automation and import the certificate to azure portal. Once we get the SSH public key, I have to create linux VM with this SSH public key(Ready this script from myend without add SSH key).

Based on my understanding, your certificate should be DER encoded X.509 certificate with .cer extension.
You can get the public key from your certificate using the PowerShell script below:
$certPath = "testcert.cer"
$x509Cert = [System.Security.Cryptography.X509Certificates.X509Certificate2]::CreateFromCertFile($certPath)
$pk = $x509Cert.GetPublicKeyString()
Hope this helps!

Related

Azure Cloud Services - Migration to Extended Support - .cer certificates

I have some .cer certificates (only public key) in my classic cloud service. I don't quite understand how am I supposed to migrate those to extended support.
.pfx certificates, I can pre-upload to Key Vault before executing New-AzCloudService with command az keyvault certificate import. That command does not work with .cer (it expects private key inside certificate).
If I don't upload the certificate, New-AzCloudService understandably fails because it can't find the certificate mentioned in .cscfg.

When creating a virtual machine with Ubuntu, how do you grab the SSH key from the keyvault through the interface?

I want to store the private key credentials in an azure keyvault. I crated the keyvault, and then generated the SSH private key that is stored in the keys blade of the keyvault. Now, I want to use the private key in my keyvault when creating the VM for the first time with Ubuntu. The problem is that through the portal, after selecting "Use existing key stored in Azure", it doesn't see any keys in my keyvault.
Basic question, how do I get the key with this method? Is it an access issue?
Any help is appreciated. Thanks.
okay,
the public key is an Azure resource that it's looking for.
the private key is the downloadable file that needs to be stored in a keyvault.

Azure - App Service Certificate in Key Vault is blank - Unable to download the pfx using powershell / az cli

I have created an Azure App Service Certificate - Wildcard and have linked it to an Azure Key Vault, also done with Domain Verification. Now I want to export this certificate as PFX and use in other components.
However, If I go to the Key Vault secret it shows up as blank.
I have tried running powershell scripts to export/download the cert but doesn't work.
The powershell script to export the cert from Key Vault is taken from https://azure.github.io/AppService/2017/02/24/Creating-a-local-PFX-copy-of-App-Service-Certificate.html
As this used the retired AzureRM module, I found a more up to date code which uses Azure Powershell scripts # https://raw.githubusercontent.com/Anitalex/poshscripts/a7e6c8153ab9f9979792eb8c07497cd42e39778d/azure/ExportWebAppCertificate.ps1
But similar set of steps..
I have tried Re-Keying the certificate in the App Service Certificate and the problem persists ?
Argh...
Here is the solution which doesn't seem to be documented anywhere..
I don't know if it's the only way, but looks like it - We have to
Create an Azure WebApp ( or an AppService)
Turn on TLS/SSL
Set an Identity - either System Assigned/User Assigned
Grant this Identity required permission to the KeyVault [ won't work with the Azure role-based access control (preview) ]
Go to the tab "Private Key Certificates (.pfx)"
Use the "Import App Service Certificate" - you will need to select your cert from the dropdowns.
Once the certificate is successfully imported, the pfx will be populated in the Key Vault certificate and now you can download.

How to store RSA key in Azure Vault

I want to store my RSA key in Azure vault, is this possible?
I did not find any methods to do this.
Please find the Microsoft link for this:
https://learn.microsoft.com/en-us/javascript/api/#azure/keyvault-keys/?view=azure-node-latest
Azure KeyVault support storing RSA keys
https://learn.microsoft.com/en-us/azure///key-vault/keys/about-keys
https://learn.microsoft.com/en-us/azure/key-vault/keys/about-keys-details
Azure SDK JavaScript
https://learn.microsoft.com/en-us/javascript/api/#azure/keyvault-keys/keyvaultkey?view=azure-node-latest#keyType
There are few ways how you can import or create RSA key in Azure Vault:
Using AzureSDK for JavaScript https://learn.microsoft.com/en-us/javascript/api/#azure/keyvault-keys/creatersakeyoptions?view=azure-node-latest
Using REST API https://learn.microsoft.com/en-us/rest/api/keyvault/importkey/importkey

Azure key vault: import pkcs12

Is there any limitation in importing pkcs12 into Azure key vault, basically I need to import a root CA cert, intermediate CA cert and a leaf cert and its private key in a single file. Is this possible with Azure key vault?
In Azure KeyVault, certificates can be imported in either PFX or PEM format, so the formats you mentioned won't work unless you convert them to PEM or PFX.
Here are some instructions for how to do that.
See more information about importing KeyVault certificates here.

Resources