Use Azure Key Vault from external web app - azure

is it possible to use Azure Key Vault for web app, which is hosted somewhere else? I'm looking for the most cost-effective way, how to do that, so ideally I would like to use really just the Key Vault. I can allow external IP in Key vault -> Networking, but I don't see any possibilities how to set up access policy for external web app in the Key vault -> Access Policies.
Any experiences or ideas how to do that?
Thanks!

but I don't see any possibilities how to set up access policy for
external web app in the Key vault -> Access Policies.
One possible way to accomplish this would be to create a Service Principal in your Azure AD and give it access to your Key Vault (under Access Policies). Then you would use this Service Principal in your "external" web app to connect to the Key Vault.

Related

How can I hide username and password in connection string in Azure App Service?

I have an app service and in the Configuration section there is a connection string that connect to a database as follows:
Server=tcp:myserver.database.windows.net,1433;Database=myDataBase;User
ID=mylogin#myserver;Password=myPassword;Trusted_Connection=False;Encrypt=True;
How can I hide the plain text password utilizing Azure services or anything else?
Azure Key Vault is a good way to hide credentials in connection strings in an Azure Web App. Here's an overview of the steps you can follow:
Create an Azure Key Vault instance.
Add the connection strings you want to store as secrets in the Key
Vault.
Grant access to the Azure Web App to retrieve secrets from the Key
Vault.
In the Azure Web App, retrieve the connection strings from the Key
Vault at runtime.
As a general approach: Use Key Vault-referenced App Settings in Azure App Service.
Your preferred way, however, should be to use Managed Identity of the App Service and then use Azure AD-based authentication for all services which support it (Azure SQL does).

Windows VM system-assigned managed identity to access Azure Key Vault in Typescript?

How we can get the Access to Azure key vault secrets from Typescript app.
We have access to the VM on which the application is running.
What are the steps and code we need to place in Type script react application to get azure key vault access?
It is not possible and not recommended to use Azure key vault in Typescript app. It is a security risk, as anyone can see your KeyVault connection details from browser console and access your secrets.
You should not access secured resources directly from client code.
https://www.npmjs.com/package/#azure/keyvault-secrets
Angular - Azure Key Vault Managing Vault Access secrets
https://learn.microsoft.com/en-us/answers/questions/318983/is-it-possible-to-use-key-vault-in-static-web-appl.html

Why don't azure portal has Azure Key Vault feature anymore while granting permissions to AD application?

I am trying to grant permissions to my Web App/API type application in Azure directory to use Azure Key Vault.
When I Required Permissions> Add API Access > Select an API, then there I can't find Azure Key Vault. I remember it was there before but not now. Where I can find it?
Image:
https://ibb.co/dswdXq
Behavior shown in your image - Azure Key Vault missing from "Select an API" blade
I have seen the behavior your image shows for a new Azure subscription, only when there were no Key Vaults so far in the Azure subscription linked to that Azure Active Directory.
Once you create a new Key Vault (you don't even need to add any keys), "Azure Key Vault" shows up while adding permissions to your app registrations in Azure AD (same steps as your image). At least, that's how it worked in my case.
Special case worth mention
You can create multiple Azure AD's in your Azure subscription and register your applications in any of them. Azure Key Vault although works in a special way and is linked to only one Azure AD, this is the Azure AD that your Azure subscription trusts (Azure Subscription also trusts only one Azure AD). So you could also run into the behavior shown in your image if you're registering application in a different Azure AD than the one your Azure subscription trusts.
Granting permissions to your Web App/API to use Key Vault
In most cases it's not even required to do the steps you're showing in your image, just for a web application to be able to access key vault since that is controlled by Azure Key Vault access policies. #junnas has already explained this part very well so you can refer to that.
You can go to your Key Vault -> Access Policies -> Add, and create a new policy for the app.
Select the app as the principal, and give it the access you want.
You don't need to touch the Authorized application option.
You should then be able to acquire tokens for Key Vault using the client id and secret (or certificate).
Key Vault does not require that you assign it to an app, unless you wanted to do delegated access.
In fact any app can acquire a token for any API that exists as a service principal in your tenant (and Key Vault does).
Of course the token itself won't contain any permissions, but Key Vault has their own access management (access policies).

Azure KeyVault with Key Rotation

Our application doesn't use keyvault until now. We are thinking of using Azure KeyVault to enforce security for keys, secrets and certificates. I read microsoft documentation on this Link. It's not clear that Azure KeyVault works with identity providers other than Azure AD. Because we are not using Azure AD but we are using Azure app service and storage account. we also want to implement key rotation with 1 hour expiry.
My questions are
Should the web app be registered with Azure AD to use KeyVault ?
While creating an azure keyvault i didn't see any option about key rotation. Am i looking in the wrong place?
Any sample code would be helpful.
When you create a key vault in an Azure subscription, it is automatically associated with the subscription's Azure Active Directory tenant. All callers (users and applications) must be registered in this tenant to access this key vault. That means to access the keys and secrets stored inside the key vault, the requesting applications have to be added in Azure active directory and it also needs to have permissions to read keys and secrets in azure key vault.
Related tutorials below are for your reference :
Get started with Azure Key Vault
How to set up Key Vault with end to end key rotation and auditing -
This walks through how to set up key rotation and auditing with Azure
Key Vault.
Azure Key Vault Developer's Guide
Use Azure Key Vault from a Web Application

What is the use of Azure Key Vault in case of WebApp

We have hosted our application on Azure WebAPP and wanted to use SSL on this. Should we use traditional way to attach this certification to Azure WebAPP or should we user Azure Key Vault. Since access to Azure WebAPP through RDP is not available and Azure is managing our WebAPP, can certification be compromised (if the Azure key vault is not used)?
I can understand its usage in case of VM, but on Azure, WebApp does it add any value.
Azure Web App doesn't rely on Azure Key Vault for any of its functionalities.
However, if you are using App Service Certificate, then you end up configuring Azure Key Vault for storing the secret. Other use cases are also there, but those are from an application perspective.

Resources