How to connect to Azure Vault from Microsoft Flow? - azure

I am trying to connect to my Azure Vault from Microsoft Power Automate - Flow.
My Vault has following access policy -
Now, I want my Microsoft Flow to access this vault and fetch the secrets sucessfully. What IP Address should I add to the Vault Firewall? Is there a way I can get the IP address being used for this Flow and then I can add that IP address in the vault firewall as exception.
I tried few things, but I am getting this error -
{
"status": 403,
"message": "Operation against key vault 'https://something.vault.azure.net/' failed as connector IP address is not authorized to call the vault. If you have configured firewall on the vault, please make sure the logic app IP addresses are allowed. Please see https://aka.ms/connectors-ip-addresses",
"error": {
"message": "Operation against key vault 'https://something.vault.azure.net/' failed as connector IP address is not authorized to call the vault. If you have configured firewall on the vault, please make sure the logic app IP addresses are allowed. Please see https://aka.ms/connectors-ip-addresses"
},
"source": "keyvault-cus.azconn-cus-001.p.azurewebsites.net"
}

I have reproduced in my environment and got expected results and followed below process:
Firstly, created a key vault as same as your settings:
Then in Flow I got similar error as below:
Then I opened my properties section of flow(Or logic app) and found connector Ip addresses:
Then inside my key vault added the Ip addresses as below:
Each ip address one line then again add then paste the add then paste till last ip address as shown in above pic. Then apply.
Then I run my Logic app and I got Secrets as below:
If you follow above process, you will get your secrets as i have got mine.
OR:
Just change your settings as below to allow all ip addresses and it works fine too.
If you can't find ip addresses of your flow, then use Managed connectors outbound IP addresses | Microsoft Learn to get ip addresses of your connector flow region.
I guess this should clear all your doubts.

Related

How can I add new secrets to Azure keyvault which has private endpoint enabled

I have a keyvault which has private endpoint enabled.
I have allowed our WAN IP on the keyvault firewall but when I browse to the "Secrets" tab then I get the following error:-
" The connection to data plane failed. Please refresh and try again.
If Private Links are enabled on the vault and the issue persists
please follow the steps in the following link
https://go.microsoft.com/fwlink/?linkid=2156688 . "
Also, I have VMs on the same subnet as the keyvault endpoint address. But the internet access is only allowed through proxy on those VMs. The subnets for these VMs are allowed on the keyvault firewall.
If try to access the keyvault from Azure console from these VMs through proxy I get following error:-
"Refresh the browser to try again.
Microsoft_Azure_KeyVault extension failed to load.
Please visit Portal Self Help to perform diagnostics."
There is a DNS problem I have noticed with our Azure hosted DNS zone. "keyvaultname.vaultcore.azure.net" does not alias to "keyvaultname.privatelink.vaultcore.azure.net" on these Azure VMs or on on-prem network. So for now I added a host file entry to resolve "keyvaultname.vaultcore.azure.net" to the private endpoint IP address.
But still the keyvault console access gives the above error on these Azure VMs.
How can I access existing secrets and add new ones to this vault using console (or powershell from the Azure VMs will be the only option to access these)?
As you said you have , please recheck and make sure firewall rule to allow that IP is created and tested if thats reaching that endpoint.
Also suggest you take a Fiddler trace to analyse the issue deeper.
Try below :
Please check to see if it works after you Clear cache/cookies/temp files.
Refresh the portal,signout and signin again .
In some cases it is browser issue so try in the different browser and see if it makes any difference.
Diagnose private links configuration issues on Azure Key Vault | Microsoft Docs

NSLookup command in Windows 10 VM for Azure key Vault is throwing error for timeout 2 seconds

In one of the on-prem server that DNS lookup for Azure key Vault is timed out. It happens randomly to the request not every time. The default server and Address is never empty and has value.
I checked port outbound port 443 is opened. I tried to clear the cache also for DNS but then also it is same thing.
Please help and advice. Thanks
I did repro and it is working for me. The missing part is you need to establish the private link connection to Key Vault using the Azure portal or Azure CLI and Select the private endpoint you wish to approve.
Please follow this document to create private link connection to key vault:
https://learn.microsoft.com/en-us/azure/key-vault/general/private-link-service?tabs=portal
Command
nslookup <your-key-vault-name>.vault.azure.net
Output –

Azure function: Detected host offline in your function app

We have an Azure Function that is integrated with VNET. Function uses Key Vault to read configuration values from. MSI has been enabled on function and access policy is added in the KV to allow function to access it. Traffic to Key Vault is restricted to be allowed from the said VNET. We have received this error in the diagnostics yesterday, which has affected our execution flow. The App was offline for a few minutes resulting in failures. This is what the diagnostic report says:
Detected host offline in your function app.
Description
A host error has occurred during startup operation 'd732fccb-40ae-40a1-8d14-ea3cdba0e725'.
Last offline at
5/4/2021 10:32:13 AM
Details
Microsoft.Azure.KeyVault.Models.KeyVaultErrorException : Client address is not authorized and caller is not a trusted service.
Client address: x.x.x.x
The function started working properly after being down for about 4 minutes. This could be an issue with VNET integration.
Has anyone encountered this? Is there any way to prevent this?
In this case, you could add the application settings WEBSITE_VNET_ROUTE_ALL = 1 of your azure function, this will force all outbound traffic from your azure function into that VNet.
When you route all of your outbound traffic into your VNet, it's
subject to the NSGs and UDRs that are applied to your integration
subnet. When WEBSITE_VNET_ROUTE_ALL is set to 1, outbound traffic is
still sent from the addresses that are listed in your app properties,
unless you provide routes that direct the traffic elsewhere.
Reference from https://learn.microsoft.com/en-us/azure/azure-functions/functions-networking-options#regional-virtual-network-integration

Azure Key Vault returns 403 with "This TCP connection does not allow access to {host}"

When I attempt to access my Key Vault using a Private Link (or maybe not, not sure), the service returns 403 (Forbidden) with this message:
This TCP connection does not allow access to {host}.
What is causing this?
This can be caused by the following reasons:
Your DNS record to the Key Vault is pointing to the wrong IP address
This is the most common reason. The following steps help diagnosing:
Go the virtual machine or client that is getting the error.
Run nslookup <key-vault-name>.vault.azure.net or the appropriate command for resolving the IP address (host <key-vault-name>.vault.azure.net for most Linuxes).
Make note of the IP address.
Using the Azure Portal, open the Key Vault resource and select Networking > Private Endpoint Connections.
Click the link under Private endpoint column. This will open the Private Endpoint resource.
Click the link at Network interface field. This will open the NIC resource.
Check the Private IP address field. That must match the one you got in nslookup or host command in step 2. If that does not match, you have to fix. For detailed instructions, see validate-the-dns-resolution topic of Azure documentation.
Your client, or some proxy you are using, is sending the wrong value at host header in the request to Key Vault
When you access Key Vault, the HTTP host header must always match the Key Vault hostname. This is the default behavior for vast majority of clients, but certain clients allow customization. Also if you use a proxy, the proxy may change this value.
Go to Key Vault resource in Azure Portal, and in the Overview tab, check the value of Vault URI property.
Extract the hostname from that property. For example, if the vault URI is https://contoso.vault.azure.net/, then the value of host header must be contoso.vault.azure.net.
Examine your client or proxy settings. Check for HTTP handlers, proxy handlers, name resolution handlers, etc. Make sure the host header sent to Key Vault service matches the one you captured in step 2.
Also make sure your client is really resolving the hostname to the IP address of your Key Vault (see previous section).
Your private endpoint is not in "approved" state, or it is approved but is not successfully provisioned
This is uncommon, but may happen when you migrate from Service Endpoints to Private Endpoints, and the migration is not complete. The following steps help diagnosing:
Go to Key Vault resource in the Azure Portal, and select Networking > Private Endpoint Connections.
Check if the connection is approved and provisioning state is succeeded. If that is not the case, fix by either approving or re-creating the Private Endpoint resource.
If the connection is approved and provisioning is succeeded, click the link below the Private endpoint column. That will open the Private Endpoint resource.
Check the properties Provisioning state and Connection status. They must show Succeeded and Approved, respectively. If they don't, you have to either approve or re-create the Private Endpoint resource.
If both the values reported in Key Vault resource and Private Endpoint resource are both approved and succeeded, you have to double-check the other possible causes.

Key Vault - Firewalls and virtual networks: Existing virtual network is not authorized

I configured the key vault to sign JWTs from my application and I limited the access to a specific virtual network and related subnet. At the beginning was working fine but suddenly it stopped working giving me the following error:
{"error":{"code":"Forbidden","message":"Client address (52.166.11.176) is not authorized and caller is not a trusted service","innererror":{"code":"ForbiddenByFirewall"}}}
I had to allow all the networks to fix the problem.
Do you have any idea about this behaviour?
Thank you
Mario
It's normal that the error happened because you had restricted restrict access to a specified virtual network, but the Client address was not coming from that authorized network. Please note that
The virtual network service endpoints for Azure Key Vault allow you to
restrict access to a specified virtual network. The endpoints also
allow you to restrict access to a list of IPv4 (internet protocol
version 4) address ranges. Any user connecting to your key vault from
outside those sources is denied access.
I suggest that you finish the key vault configuration before you limit the network access to a specific virtual network.
Ref: Virtual network service endpoints for Azure Key Vault

Resources