File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ import (
2020 "fmt"
2121 "net/http"
2222 "strings"
23+ "time"
2324
2425 "github.com/Azure/azure-sdk-for-go/sdk/azcore"
2526 "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
@@ -107,6 +108,10 @@ type azure struct {
107108func (a * azure ) GetAccessToken (ctx context.Context ) (string , error ) {
108109 log := log .FromContext (ctx )
109110
111+ // Try Azure with a short timeout
112+ timeoutCtx , cancel := context .WithTimeout (context .Background (), 10 * time .Second )
113+ defer cancel ()
114+
110115 // To prevent clogging logs every time JWT is generated
111116 initializing := a .cred == nil
112117
@@ -122,7 +127,7 @@ func (a *azure) GetAccessToken(ctx context.Context) (string, error) {
122127 log .Info (fmt .Sprintf ("generating Default Azure Credentials with scopes %s" , strings .Join (a .scopes , " " )))
123128
124129 // Request a token with the provided scopes
125- token , err := a .cred .GetToken (ctx , policy.TokenRequestOptions {
130+ token , err := a .cred .GetToken (timeoutCtx , policy.TokenRequestOptions {
126131 Scopes : a .scopes ,
127132 })
128133 if err != nil {
You can’t perform that action at this time.
0 commit comments