1

I am working on a front end application feature to get the details from all the key vault certificates and when they expire. The app uses the service connection to authenticate and the azure-devops-sdk and azure-devops-api to pull back data for api calls. I am currently getting data back on the contents within the key vault but it only lists the permissions for the certificates - https://learn.microsoft.com/en-us/rest/api/keyvault/getcertificate/getcertificates. I've tried appending /certificates on the end of the api call but it is not a valid endpoint.

I am aware of the azure rest api which returns this data - https://learn.microsoft.com/en-us/rest/api/keyvault/vaults/get but I am not sure how to implement this with the service connection.

Does anyone have any ideas on how I can gets this data back with the service connection?

export async function getCertInfoFromAzure(endpoint) {
    requestInitialData = await getRequestInitialData();
    const {project, settings, client} = requestInitialData;
    const subscriptionId = endpoint.data.subscriptionId;
    const apiVersion = providerMap['Microsoft.KeyVault'.toLowerCase()];
    const resourceId = '/subscriptions/<subscription name> /resourceGroups/<resource group name>/providers/Microsoft.KeyVault/vaults/<key vault name>/';
    const seRequest: ServiceEndpointRequest = createRequestObject(
        `{{{endpoint.url}}}${resourceId}?api-version=${`2019-09-01`}`,
        'jsonpath:$');
    const response = await client.executeServiceEndpointRequest(seRequest, project.id, endpoint.id);
    console.log('response', response);
    console.log(JSON.parse(response.result));
    console.log('seRequest', seRequest)
    return {
        response: JSON.parse(response.result[0]),
    };
}
Allen Wu
  • 15,529
  • 1
  • 9
  • 20

0 Answers0