getting `No HTTP resource was found that matches the request URI` on privateEndpointConnections API call

Harshavardhan 21 Reputation points
2022-11-29T17:52:36.493+00:00

Below is the python code I use to get private endpoints for the key vaults I have in my Azure account.

vaults_url = "https://management.azure.com/subscriptions/{}/resources?$filter=resourceType eq 'Microsoft.KeyVault/vaults'&api-version=2015-11-01".format(self.sub_id)  
vaults_resp = requests.get(vaults_url, headers=self.headers)  
vaults_resp = vaults_resp.json()  
if vaults_resp.get('error'):  
    raise Exception("{}, message: {}".format(vaults_resp.get('error', {}).get('code'),  
                                             str(vaults_resp.get('error', {}).get('message'))))  
for vault in vaults_resp.get('value', []):  
    rg = vault.get('id', '').split('/')[4]  
    pprint(f"{vault=};{rg=}")  
    print(self.sub_id, rg, vault.get('name'))  
    list_private_ep_url = AzureRestApiEndpoint.list_key_vaults_list_pvt_ep_conn_by_resource.format(self.sub_id, rg, vault.get('name'))  
    print(f"{list_private_ep_url=}")  
    private_eps_url = requests.get(list_private_ep_url, headers=self.headers)  
    private_eps_url = private_eps_url.json()  
    if private_eps_url.get('error'):  
        raise Exception("{}, message: {}".format(private_eps_url.get('error', {}).get('code'),  
                                                 str(private_eps_url.get('error', {}).get('message'))))  
    print(f"{private_eps_url=}")  

But upon running the script, I am getting the below error:

{'Message': "No HTTP resource was found that matches the request URI 'https://control-prod-cin.vaultcore.azure.net/subscriptions/{subscription-id}/resourceGroups/{rg-name}/providers/Microsoft.KeyVault/vaults/{vault-name}/privateEndpointConnections?api-version=2022-07-01'."}

The previous 2 API calls work fine with valid response.

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.
1,184 questions
0 comments No comments
{count} votes

Accepted answer
  1. JamesTran-MSFT 36,536 Reputation points Microsoft Employee
    2022-12-01T00:55:27.36+00:00

    @Harshavardhan
    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others", I'll repost your solution in case you'd like to "Accept" the answer.

    Issue:
    When running your python script to get private endpoints for the key vaults, you ran into the below error message.

    Error Message:
    No HTTP resource was found that matches the request URI 'https://control-.../subscriptions/{subscription-id}/resourceGroups/{rg-name}/providers/Microsoft.KeyVault/vaults/{vault-name}/privateEndpointConnections?api-version=2022-07-01

    Solution:
    From your error message, you were able to resolve the issue by using the correct Key Vault Private Endpoint Connections - List By Resource API call.

    GET https://management.azure.com/subscriptions/{subId}/resourceGroups/{rg-Name}/providers/Microsoft.KeyVault/vaults/{vaultName}/privateEndpointConnections?api-version=2022-07-01  
    

    If you have any other questions or came to a different solution, please let me know and I can definitely update my answer.
    Thank you again for your time and patience throughout this issue.

    ----------

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Harshavardhan 21 Reputation points
    2022-11-30T17:32:21.543+00:00

    My apologies, the issue was on my end. I didn't construct the proper URL get-private-endpoints API call.

    0 comments No comments