File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
src/Microsoft.DotNet.ImageBuilder/src Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -63,8 +63,20 @@ Attempted to get Service Connection credential but SYSTEM_ACCESSTOKEN environmen
63
63
_systemAccessToken ) ;
64
64
}
65
65
66
+ #if DEBUG
66
67
// Fall back to DefaultAzureCredential if no service connection is provided.
68
+ // This can still be used for local development against non-production resources.
67
69
credential ??= new DefaultAzureCredential ( ) ;
70
+ #endif
71
+
72
+ if ( credential is null )
73
+ {
74
+ // Using DefaultAzureCredential is not allowed in production environments.
75
+ throw new InvalidOperationException (
76
+ "Attempted to get an Azure Pipelines Credential but no service connection was provided."
77
+ ) ;
78
+ }
79
+
68
80
var accessToken = credential . GetToken ( new TokenRequestContext ( [ scope ] ) , CancellationToken . None ) ;
69
81
return new StaticTokenCredential ( accessToken ) ;
70
82
} ) ;
You can’t perform that action at this time.
0 commit comments