azureazureportalazure-cdnazure-rest-apiazure-management-api

Azure CDN Rest API Returns an empty array of Profiles and Endpoints


I'm currently working on an Azure Front Door Application that contains cache. The idea is that we have a webhook that would call our API to fetch the endpoint and purge the cache.

I've already added the CDN Endpoint Contributor permission to my service principal and I've been able to authenticate using Auth Flow without any issues enter image description here

The problem arises when I have to fetch whatever from the Azure rest API.

All my requests go trough using the token and present a successful response. But, all the responses are empty.

Example of fetching the endpoints inside my app, using the API enter image description here

But, in Azure Portal, you can clearly see that there are endpoints available ( they were created weeks ago so it's not a propagation issue ).

Does anyone have any clue what this could be? Any help would be appreciated, thanks.


Solution

  • I created an endpoint:

    enter image description here

    Granted API permissions to Microsoft Entra ID application:

    enter image description here

    Added CDN Endpoint Contributor permission to the service principal:

    enter image description here

    Generated access token:

    GET https://login.microsoftonline.com/TenantID/oauth2/v2.0/token
    
    client_id:ClientID
    scope:https://management.azure.com/.default
    client_secret:Secret
    grant_type:client_credentials
    

    enter image description here

    I am able to get the response successfully:

    GET https://management.azure.com/subscriptions/SubID/resourceGroups/ruk/providers/Microsoft.Cdn/profiles/rukprofile/endpoints/ruk?api-version=2024-02-01
    

    enter image description here

    If still the issue persists as mentioned by you refer this SO Thread by Wesley Smith.