
- Creating and configuring CDN profiles and endpoints.
- Listing and inspecting CDN profiles and their endpoints.
- Purging endpoint caches to force fresh content from the origin.
- Retrieving configuration and operational details for monitoring and automation.
- How to authenticate the .NET SDK to Azure using DefaultAzureCredential.
- How to instantiate a CdnManagementClient.
- How to list CDN profiles in a resource group and enumerate their endpoints.
- Notes about permissions and purging cached content.
Prerequisites
- An Azure subscription and a resource group containing CDN profiles.
- Appropriate Azure RBAC role (for listing, Reader on the resource group is sufficient; for create/purge you need Contributor or specific CDN roles).
- .NET 6+ (or supported .NET version) development environment.
- NuGet packages:
Azure.Identity(for DefaultAzureCredential)Azure.CoreMicrosoft.Azure.Management.CdnMicrosoft.Rest.ClientRuntime(forTokenCredentials)
DefaultAzureCredential attempts multiple authentication methods (environment variables, managed identity, Visual Studio/VS Code sign-in, Azure CLI, etc.). When running locally, sign in with the Azure CLI (az login) or Visual Studio/VS Code. The caller must have the required Azure RBAC permissions to list or manage CDN resources.- Acquiring an Azure AD token using
DefaultAzureCredential. - Converting that token into a
TokenCredentialsinstance for the management client. - Listing all CDN profiles in a resource group and enumerating their endpoints.
- Authentication: The sample uses
DefaultAzureCredentialto obtain an Azure AD access token scoped for Azure Resource Manager (https://management.azure.com/.default). That token is wrapped in aTokenCredentialsinstance required byCdnManagementClient. - SubscriptionId: Set to the subscription containing your CDN profiles.
- Resource group: Provide the name of the resource group that contains your CDN profiles when calling
ListByResourceGroup. - Correct parameter order: To list endpoints for a profile, call
Endpoints.ListByProfile(resourceGroupName, profileName)— the first parameter is the resource group name, the second is the profile name. - Purging content: The SDK supports endpoint purge operations (e.g.,
Endpoints.PurgeContent), which you use to clear cached content so updated content is fetched from the origin. - Permissions: For read operations,
Readeron the resource group is sufficient; for create/update/purge operations, useContributoror granular CDN permissions.
- Azure CDN overview
- Azure .NET SDK authentication (DefaultAzureCredential)
- Microsoft.Azure.Management.Cdn NuGet package