@@ -97,26 +97,27 @@ export async function loadFromCdn(
9797 const emptyTokenCredential : TokenCredential = {
9898 getToken : async ( ) => ( { token : "" , expiresOnTimestamp : 0 } )
9999 } ;
100+
100101 // the api version supports sas token authentication
101102 const apiVersion = "2024-09-01-preview" ;
102103 const policyName = "CdnRequestApiVersionPolicy" ;
103-
104104 const apiVersionPolicy : PipelinePolicy = {
105105 name : policyName ,
106106 sendRequest : async ( request : PipelineRequest , next : SendRequest ) => {
107107 const url = new URL ( request . url ) ;
108108 url . searchParams . set ( "api-version" , apiVersion ) ;
109- request . url = url . toString ( ) ;
109+ request . url = url . toString ( ) ;
110110 return next ( request ) ;
111111 } ,
112112 } ;
113-
114113 if ( appConfigOptions === undefined ) {
115114 appConfigOptions = { clientOptions : { } } ;
116115 }
117116 const policies = appConfigOptions . clientOptions ?. additionalPolicies || [ ] ;
118- policies . push ( { policy : apiVersionPolicy , position : "perCall" } ) ;
119- appConfigOptions . clientOptions = { ...appConfigOptions . clientOptions , additionalPolicies : policies } ;
117+ // The policy position should be perRetry so that the policy will be processed after the api version policy added by the SDK.
118+ // https://learn.microsoft.com/en-us/dotnet/api/azure.core.httppipelineposition?view=azure-dotnet#fields
119+ policies . push ( { policy : apiVersionPolicy , position : "perRetry" } ) ;
120+ appConfigOptions . clientOptions = { ...appConfigOptions . clientOptions , additionalPolicies : policies } ;
120121
121122 return await load ( cdnEndpoint , emptyTokenCredential , appConfigOptions ) ;
122123}
0 commit comments