Skip to content

Commit bac7248

Browse files
author
Maxwell Gattuso
committed
Update cdn-manage-powershell.md
1 parent 97d1127 commit bac7248

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

articles/cdn/cdn-manage-powershell.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ms.workload: tbd
1313
ms.tgt_pltfrm: na
1414
ms.devlang: na
1515
ms.topic: article
16-
ms.date: 09/13/2018
16+
ms.date: 11/20/2019
1717
ms.author: magattus
1818

1919
---
@@ -232,6 +232,29 @@ Get-AzCdnProfile | Get-AzCdnEndpoint | Stop-AzCdnEndpoint
232232
Get-AzCdnProfile | Get-AzCdnEndpoint | Start-AzCdnEndpoint
233233
```
234234

235+
## Creating Standard Rules engine policy and applying to an existing CDN endpoint
236+
`New-AzCdnDeliveryRule`, `New=AzCdnDeliveryRuleCondition`, and `New-AzCdnDeliveryRuleAction` can be used to configure the Azure CDN Standard Rules engine on Azure CDN from Microsoft profiles.
237+
238+
```powershell
239+
# Create a new http to https redirect rule
240+
$Condition=New-AzCdnDeliveryRuleCondition -MatchVariable RequestProtocol -Operator Equal -MatchValue HTTP
241+
$Action=New-AzCdnDeliveryRuleAction -RedirectType Found -DestinationProtocol HTTPS
242+
$HttpToHttpsRedirectRule=New-AzCdnDeliveryRule -Name "HttpToHttpsRedirectRule" -Order 2 -Condition $Condition -Action $Action
243+
244+
# Create a path based Response header modification rule.
245+
$Cond1=New-AzCdnDeliveryRuleCondition -MatchVariable UrlPath -Operator BeginsWith -MatchValue "/images/"
246+
$Action1=New-AzCdnDeliveryRuleAction -HeaderActionType ModifyResponseHeader -Action Overwrite -HeaderName "Access-Control-Allow-Origin" -Value "*"
247+
$PathBasedCacheOverrideRule=New-AzCdnDeliveryRule -Name "PathBasedCacheOverride" -Order 1 -Condition $Cond1 -Action $action1
248+
249+
# Create a delivery policy with above deliveryRules.
250+
$Policy = New-AzCdnDeliveryPolicy -Description "DeliveryPolicy" -Rule $HttpToHttpsRedirectRule,$UrlRewriteRule
251+
252+
# Update existing endpoint with created delivery policy
253+
$ep = Get-AzCdnEndpoint -EndpointName cdndocdemo -ProfileName CdnDemo -ResourceGroupName CdnDemoRG
254+
$ep.DeliveryPolicy = $Policy
255+
Set-AzCdnEndpoint -CdnEndpoint $ep
256+
```
257+
235258
## Deleting CDN resources
236259
`Remove-AzCdnProfile` and `Remove-AzCdnEndpoint` can be used to remove profiles and endpoints.
237260

0 commit comments

Comments
 (0)