| ROBOTS | NOINDEX |
|---|---|
| title | Manage Azure Content Delivery Network with PowerShell |
| description | Use this tutorial to learn how to use PowerShell to manage aspects of your Azure Content Delivery Network endpoint profiles and endpoints. |
| services | cdn |
| author | halkazwini |
| ms.author | halkazwini |
| manager | kumudd |
| ms.service | azure-cdn |
| ms.topic | how-to |
| ms.date | 02/28/2026 |
| ms.custom | devx-track-azurepowershell |
Important
- Starting August 15, 2025, Azure CDN from Microsoft (classic) will no longer support new domain onboarding or profile creation. Migrate to AFD Standard and Premium to create new domains or profiles and avoid service disruption. Learn more
- Starting August 15, 2025, Azure CDN from Microsoft (classic) will no longer support Managed certificates. To avoid service disruption, either switch to Bring Your Own Certificate (BYOC) or migrate to AFD Standard and Premium by this date. Existing managed certificates will be auto renewed before August 15, 2025, and remain valid until April 14, 2026. Learn more
- Azure CDN Standard from Microsoft (classic) will be retired on September 30, 2027. To avoid service disruption migrate to AFD Standard or Premium. Learn more.
- Azure CDN from Edgio was retired on January 15, 2025. Learn more.
PowerShell provides one of the most flexible methods to manage your Azure Content Delivery Network profiles and endpoints. You can use PowerShell interactively or by writing scripts to automate management tasks. This tutorial demonstrates several of the most common tasks you can accomplish with PowerShell to manage your Azure Content Delivery Network profiles and endpoints.
[!INCLUDE updated-for-az]
To use PowerShell to manage your Azure Content Delivery Network profiles and endpoints, you must have the Azure PowerShell module installed. To learn how to install Azure PowerShell and connect to Azure using the Connect-AzAccount cmdlet, see How to install and configure Azure PowerShell.
Important
You must log in with Connect-AzAccount before you can execute Azure PowerShell cmdlets.
You can list all the Azure Content Delivery Network cmdlets using the Get-Command cmdlet.
PS C:\> Get-Command -Module Az.Cdn
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Confirm-AzCdnEndpointProbeURL 2.1.0 Az.Cdn
Cmdlet Disable-AzCdnCustomDomain 2.1.0 Az.Cdn
Cmdlet Disable-AzCdnCustomDomainHttps 2.1.0 Az.Cdn
Cmdlet Enable-AzCdnCustomDomain 2.1.0 Az.Cdn
Cmdlet Enable-AzCdnCustomDomainHttps 2.1.0 Az.Cdn
Cmdlet Get-AzCdnCustomDomain 2.1.0 Az.Cdn
Cmdlet Get-AzCdnEdgeNode 2.1.0 Az.Cdn
Cmdlet Get-AzCdnEndpoint 2.1.0 Az.Cdn
Cmdlet Get-AzCdnEndpointResourceUsage 2.1.0 Az.Cdn
Cmdlet Get-AzCdnOrigin 2.1.0 Az.Cdn
Cmdlet Get-AzCdnProfile 2.1.0 Az.Cdn
Cmdlet Get-AzCdnProfileResourceUsage 2.1.0 Az.Cdn
Cmdlet Get-AzCdnProfileSupportedOptimizationType 2.1.0 Az.Cdn
Cmdlet Get-AzCdnSubscriptionResourceUsage 2.1.0 Az.Cdn
Cmdlet New-AzCdnCustomDomain 2.1.0 Az.Cdn
Cmdlet New-AzCdnDeliveryPolicy 2.1.0 Az.Cdn
Cmdlet New-AzCdnDeliveryRule 2.1.0 Az.Cdn
Cmdlet New-AzCdnDeliveryRuleAction 2.1.0 Az.Cdn
Cmdlet New-AzCdnDeliveryRuleCondition 2.1.0 Az.Cdn
Cmdlet New-AzCdnEndpoint 2.1.0 Az.Cdn
Cmdlet New-AzCdnProfile 2.1.0 Az.Cdn
Cmdlet Remove-AzCdnCustomDomain 2.1.0 Az.Cdn
Cmdlet Remove-AzCdnEndpoint 2.1.0 Az.Cdn
Cmdlet Remove-AzCdnProfile 2.1.0 Az.Cdn
Cmdlet Set-AzCdnProfile 2.1.0 Az.Cdn
Cmdlet Start-AzCdnEndpoint 2.1.0 Az.Cdn
Cmdlet Stop-AzCdnEndpoint 2.1.0 Az.Cdn
You can get help with any of these cmdlets using the Get-Help cmdlet. Get-Help provides usage and syntax, and optionally shows examples.
PS C:\> Get-Help Get-AzCdnProfile
NAME
Get-AzCdnProfile
SYNOPSIS
Gets an Azure CDN profile.
SYNTAX
Get-AzCdnProfile [-ProfileName <String>] [-ResourceGroupName <String>] [-InformationAction
<ActionPreference>] [-InformationVariable <String>] [<CommonParameters>]
DESCRIPTION
Gets an Azure CDN profile and all related information.
RELATED LINKS
https://learn.microsoft.com/powershell/module/az.cdn/get-azcdnprofile
REMARKS
To see the examples, type: "get-help Get-AzCdnProfile -examples".
For more information, type: "get-help Get-AzCdnProfile -detailed".
For technical information, type: "get-help Get-AzCdnProfile -full".
For online help, type: "get-help Get-AzCdnProfile -online"
The Get-AzCdnProfile cmdlet without any parameters retrieves all your existing content delivery network profiles.
Get-AzCdnProfileThis output can be piped to cmdlets for enumeration.
# Output the name of all profiles on this subscription.
Get-AzCdnProfile | ForEach-Object { Write-Host $_.Name }You can also return a single profile by specifying the profile name and resource group.
Get-AzCdnProfile -ProfileName CdnDemo -ResourceGroupName CdnDemoRGTip
It is possible to have multiple content delivery network profiles with the same name, so long as they are in different resource groups. Omitting the ResourceGroupName parameter returns all profiles with a matching name.
Get-AzCdnEndpoint can retrieve an individual endpoint or all the endpoints on a profile.
# Get a single endpoint.
Get-AzCdnEndpoint -ProfileName CdnDemo -ResourceGroupName CdnDemoRG -EndpointName cdndocdemo
# Get all of the endpoints on a given profile.
Get-AzCdnEndpoint -ProfileName CdnDemo -ResourceGroupName CdnDemoRGNew-AzCdnProfile and New-AzCdnEndpoint are used to create content delivery network profiles and endpoints. The following SKUs are supported:
- Standard_Verizon
- Premium_Verizon
- Custom_Verizon
- Standard_Microsoft
- Standard_ChinaCdn
# Create a new profile
New-AzCdnProfile -ProfileName CdnPoshDemo -ResourceGroupName CdnDemoRG -Sku Standard_Microsoft -Location "Central US"
# Create a new endpoint
$origin = @{
Name = "Contoso"
HostName = "www.contoso.com"
};
New-AzCdnEndpoint -ProfileName CdnPoshDemo -ResourceGroupName CdnDemoRG -Location "Central US" -EndpointName cdnposhdoc -Origin $originNew-AzCdnCustomDomain adds a custom domain name to an existing endpoint.
Important
You must set up the CNAME with your DNS provider as described in How to map Custom Domain to Content Delivery Network endpoint. You can test the mapping before modifying your endpoint using Test-AzCdnCustomDomain.
# Create the custom domain on the endpoint
New-AzCdnCustomDomain -ResourceGroupName CdnDemoRG -ProfileName CdnPoshDemo -Name contoso -HostName "cdn.contoso.com" -EndpointName cdnposhdocUpdate-AzCdnEndpoint modifies an existing endpoint.
# Update endpoint with compression settings
Update-AzCdnEndpoint -Name cdnposhdoc -ProfileName CdnPoshDemo -ResourceGroupName CdnDemoRG -IsCompressionEnabled -ContentTypesToCompress "text/javascript","text/css","application/json"Clear-AzCdnEndpointContent purges cached assets.
# Purge some assets.
Clear-AzCdnEndpointContent -ProfileName CdnPoshDemo -ResourceGroupName CdnDemoRG -EndpointName cdnposhdoc -ContentFilePath @("/images/kitten.png","/video/rickroll.mp4")Start-AzCdnEndpoint and Stop-AzCdnEndpoint can be used to start and stop individual endpoints or groups of endpoints.
# Stop the CdnPoshDemo endpoint
Stop-AzCdnEndpoint -ProfileName CdnPoshDemo -ResourceGroupName CdnDemoRG -Name cdnposhdoc
# Start the CdnPoshDemo endpoint
Start-AzCdnEndpoint -ProfileName CdnPoshDemo -ResourceGroupName CdnDemoRG -Name cdnposhdocThe following list of cmdlets can be used to create a Standard Rules engine policy and apply it to an existing content delivery network endpoint.
Conditions:
- New-AzFrontDoorCdnRuleCookiesConditionObject
- New-AzCdnDeliveryRuleHttpVersionConditionObject
- New-AzCdnDeliveryRuleIsDeviceConditionObject
- New-AzCdnDeliveryRulePostArgsConditionObject
- New-AzCdnDeliveryRuleQueryStringConditionObject
- New-AzCdnDeliveryRuleRemoteAddressConditionObject
- New-AzCdnDeliveryRuleRequestBodyConditionObject
- New-AzCdnDeliveryRuleRequestHeaderConditionObject
- New-AzCdnDeliveryRuleRequestMethodConditionObject
- New-AzCdnDeliveryRuleRequestSchemeConditionObject
- New-AzCdnDeliveryRuleRequestUriConditionObject
- New-AzCdnDeliveryRuleResponseHeaderActionObject
- New-AzCdnDeliveryRuleUrlFileExtensionConditionObject
- New-AzCdnDeliveryRuleUrlFileNameConditionObject
- New-AzCdnDeliveryRuleUrlPathConditionObject
Actions:
- New-AzCdnDeliveryRuleRequestHeaderActionObject
- New-AzCdnDeliveryRuleRequestHeaderActionObject
- New-AzCdnUrlRedirectActionObject
- New-AzCdnUrlRewriteActionObject
- New-AzCdnUrlSigningActionObject
# Create a path based Response header modification rule.
$cond1 = New-AzCdnDeliveryRuleUrlPathConditionObject -Name UrlPath -ParameterOperator BeginsWith -ParameterMatchValue "/images/"
$action1 = New-AzCdnDeliveryRuleResponseHeaderActionObject -Name ModifyResponseHeader -ParameterHeaderAction Overwrite -ParameterHeaderName "Access-Control-Allow-Origin" -ParameterValue "*"
$rule1 = New-AzCdnDeliveryRuleObject -Name "PathBasedCacheOverride" -Order 1 -Condition $cond1 -Action $action1
# Create a new http to https redirect rule
$cond1 = New-AzCdnDeliveryRuleRequestSchemeConditionObject -Name RequestScheme -ParameterMatchValue HTTPS
$action1 = New-AzCdnUrlRedirectActionObject -Name UrlRedirect -ParameterRedirectType Found -ParameterDestinationProtocol Https
$rule2 = New-AzCdnDeliveryRuleObject -Name "UrlRewriteRule" -Order 2 -Condition $cond1 -Action $action1
# Update existing endpoint with new rules
Update-AzCdnEndpoint -Name cdnposhdoc -ProfileName CdnPoshDemo -ResourceGroupName CdnDemoRG -DeliveryPolicyRule $rule1,$rule2Remove-AzCdnProfile and Remove-AzCdnEndpoint can be used to remove profiles and endpoints.
# Remove a single endpoint
Remove-AzCdnEndpoint -ProfileName CdnPoshDemo -ResourceGroupName CdnDemoRG -EndpointName cdnposhdoc
# Remove a single profile
Remove-AzCdnProfile -ProfileName CdnPoshDemo -ResourceGroupName CdnDemoRG-
Learn how to automate Azure Content Delivery Network with .NET or Node.js.
-
To learn about content delivery network features, see content delivery network Overview.