Skip to main content
Using the .NET Azure Content Delivery Network (CDN) library to automate creation, management, and monitoring of CDN profiles and endpoints.
A presentation slide titled "Using .NET Azure Content Delivery Network Library" with a stylized blue .NET logo on a teal curved background. The slide also shows a small "© Copyright KodeKloud" note in the corner.
Overview The Azure CDN .NET SDK lets .NET developers manage Azure CDN resources programmatically, enabling integration with applications, deployment pipelines, and automation scripts. Typical tasks you can perform with the SDK include:
  • 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.
What you’ll learn
  • 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.
Quick reference: common SDK actions 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.Core
    • Microsoft.Azure.Management.Cdn
    • Microsoft.Rest.ClientRuntime (for TokenCredentials)
Install packages (example)
Authentication note
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.
Example: List CDN profiles and endpoints using the Azure .NET SDK This concise example demonstrates:
  • Acquiring an Azure AD token using DefaultAzureCredential.
  • Converting that token into a TokenCredentials instance for the management client.
  • Listing all CDN profiles in a resource group and enumerating their endpoints.
Explanation and important notes
  • Authentication: The sample uses DefaultAzureCredential to obtain an Azure AD access token scoped for Azure Resource Manager (https://management.azure.com/.default). That token is wrapped in a TokenCredentials instance required by CdnManagementClient.
  • 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, Reader on the resource group is sufficient; for create/update/purge operations, use Contributor or granular CDN permissions.
Further resources If you prefer portal or CLI workflows, the Azure portal, Azure CLI, and Azure PowerShell are fully supported alternatives. The .NET SDK is ideal when you need to embed CDN management into applications or automation pipelines.

Watch Video