Before this change, we only support asynchronously setting authorization token, but not for Azure region. Thus, if you have multiple subscription keys used in different Azure regions, it is not trivial to renew the authentication token while moving to another Azure region.
In this PR, we unified all credentials options into a single option namely credentials. It inherits previous signature which support Promise-based function or simple objects.
You can use the new credentials object to set the Azure region, and your choice of either authorization token or subscription key.
Changelog
Breaking changes
Unifying options to pass credentials
authorizationToken, region, and subscriptionKey are being deprecated in favor of credentials options. credentials can be one of the following types:
If credentials is a function, it will be called just before the credentials is needed and may be called very frequently. This behavior matches the deprecating authorizationToken. The result of the call is also expected to be cached.
If region is not returned, the default value of "westus" will be used.
Removed
🔥 authorizationToken, region, and subscriptionKey are being deprecated in favor of credentials options, by @compulim in PR #80
Added
credentials option is added for obtaining authorization token and region, or subscription key and region, in a single object or function call, by @compulim in PR #80
Description
Before this change, we only support asynchronously setting authorization token, but not for Azure region. Thus, if you have multiple subscription keys used in different Azure regions, it is not trivial to renew the authentication token while moving to another Azure region.
In this PR, we unified all credentials options into a single option namely
credentials
. It inherits previous signature which support Promise-based function or simple objects.You can use the new
credentials
object to set the Azure region, and your choice of either authorization token or subscription key.Changelog
Breaking changes
Unifying options to pass credentials
authorizationToken
,region
, andsubscriptionKey
are being deprecated in favor ofcredentials
options.credentials
can be one of the following types:{ authorizationToken: string, region: string? }
{ region: string?, subscriptionKey: string }
Promise<{ authorizationToken: string, region: string? }>
Promise<{ region: string?, subscriptionKey: string }>
() => { authorizationToken: string, region: string? }
() => { region: string?, subscriptionKey: string }
() => Promise<{ authorizationToken: string, region: string? }>
() => Promise<{ region: string?, subscriptionKey: string }>
If
credentials
is a function, it will be called just before the credentials is needed and may be called very frequently. This behavior matches the deprecatingauthorizationToken
. The result of the call is also expected to be cached.If
region
is not returned, the default value of"westus"
will be used.Removed
authorizationToken
,region
, andsubscriptionKey
are being deprecated in favor ofcredentials
options, by @compulim in PR #80Added
credentials
option is added for obtaining authorization token and region, or subscription key and region, in a single object or function call, by @compulim in PR #80