-
Notifications
You must be signed in to change notification settings - Fork 1.1k
.NET: Use DefaultAzureCredential instead of AzureCliCredential #3860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET: Use DefaultAzureCredential instead of AzureCliCredential #3860
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates all .NET sample code to use DefaultAzureCredential instead of AzureCliCredential for Azure authentication, addressing customer feedback that they use various credential types (e.g., EnvironmentCredential). The change enables samples to work with multiple authentication methods while maintaining backward compatibility with Azure CLI authentication.
Changes:
- Replaced all instances of
AzureCliCredentialwithDefaultAzureCredentialacross 100+ sample files - Added consistent WARNING comments to all credential instantiations explaining production considerations
- Updated documentation in README files to reference
DefaultAzureCredentialwhere modified
Reviewed changes
Copilot reviewed 113 out of 113 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/samples/Purview/AgentWithPurview/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/M365Agent/README.md | Updated documentation to reference DefaultAzureCredential |
| dotnet/samples/M365Agent/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/HostedAgents/AgentsInWorkflows/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/HostedAgents/AgentWithTextSearchRag/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/HostedAgents/AgentWithHostedMCP/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/_Foundational/08_WriterCriticWorkflow/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/_Foundational/07_MixedWorkflowAgentsAndExecutors/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/_Foundational/04_AgentWorkflowPatterns/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/_Foundational/03_AgentsInWorkflows/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Observability/WorkflowAsAnAgent/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Declarative/ToolApproval/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Declarative/StudentTeacher/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Declarative/Marketing/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Declarative/InputArguments/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Declarative/HostedWorkflow/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Declarative/FunctionTools/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Declarative/ExecuteWorkflow/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Declarative/ExecuteCode/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Declarative/DeepResearch/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Declarative/CustomerSupport/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/ConditionalEdges/03_MultiSelection/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/ConditionalEdges/02_SwitchCase/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/ConditionalEdges/01_EdgeCondition/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Concurrent/Concurrent/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Agents/WorkflowAsAnAgent/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Agents/GroupChatToolApproval/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Agents/FoundryAgent/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Workflows/Agents/CustomAgentExecutors/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/ModelContextProtocol/ResponseAgent_Hosted_MCP/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/ModelContextProtocol/FoundryAgent_Hosted_MCP/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/ModelContextProtocol/Agent_MCP_Server_Auth/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/ModelContextProtocol/Agent_MCP_Server/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step27_LocalMCP/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step15_ComputerUse/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step14_CodeInterpreter/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step13_Plugins/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step12_Middleware/README.md | Updated documentation to reference DefaultAzureCredential |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step12_Middleware/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step11_AsFunctionTool/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step10_UsingImages/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step09_UsingMcpClientAsTools/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step08_DependencyInjection/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step07_Observability/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step06_PersistedConversations/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step05_StructuredOutput/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step04_UsingFunctionToolsWithApprovals/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03_UsingFunctionTools/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step02_MultiturnConversation/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.2_Running/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.1_Basics/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/DevUI/DevUI_Step01_BasicUsage/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/DeclarativeAgents/ChatClient/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step20_AdditionalAIContext/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step19_Declarative/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step18_DeepResearch/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step17_BackgroundResponses/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step16_ChatReduction/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step15_Plugins/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step14_Middleware/README.md | Updated documentation to reference DefaultAzureCredential |
| dotnet/samples/GettingStarted/Agents/Agent_Step14_Middleware/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step13_BackgroundResponsesWithToolsAndPersistence/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step12_AsFunctionTool/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step11_UsingImages/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step10_AsMcpTool/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step09_DependencyInjection/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step08_Observability/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyChatHistoryStorage/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step06_PersistedConversations/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step05_StructuredOutput/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step04_UsingFunctionToolsWithApprovals/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step03_UsingFunctionTools/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step02_MultiturnConversation/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/Agents/Agent_Step01_Running/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentWithRAG/AgentWithRAG_Step04_FoundryServiceRAG/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentWithRAG/AgentWithRAG_Step03_CustomRAGDataSource/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentWithRAG/AgentWithRAG_Step02_CustomVectorStoreRAG/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentWithRAG/AgentWithRAG_Step01_BasicTextRAG/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentWithMemory/AgentWithMemory_Step03_CustomMemory/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentWithMemory/AgentWithMemory_Step02_MemoryUsingMem0/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentWithMemory/AgentWithMemory_Step01_ChatHistoryMemory/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIResponses/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureOpenAIChatCompletion/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundryModel/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIProject/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgentsPersistent/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentProviders/Agent_With_Anthropic/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AgentOpenTelemetry/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AGUI/Step05_StateManagement/Server/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AGUI/Step04_HumanInLoop/Server/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AGUI/Step03_FrontendTools/Server/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AGUI/Step02_BackendTools/Server/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/AGUI/Step01_GettingStarted/Server/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/GettingStarted/A2A/A2AAgent_AsFunctionTools/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/ConsoleApps/07_ReliableStreaming/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/ConsoleApps/06_LongRunningTools/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/ConsoleApps/05_AgentOrchestration_HITL/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/ConsoleApps/04_AgentOrchestration_Conditionals/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/ConsoleApps/03_AgentOrchestration_Concurrency/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/ConsoleApps/02_AgentOrchestration_Chaining/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/ConsoleApps/01_SingleAgent/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/AzureFunctions/08_ReliableStreaming/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/AzureFunctions/07_AgentAsMcpTool/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/AzureFunctions/06_LongRunningTools/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/AzureFunctions/05_AgentOrchestration_HITL/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/AzureFunctions/04_AgentOrchestration_Conditionals/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/AzureFunctions/03_AgentOrchestration_Concurrency/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/AzureFunctions/02_AgentOrchestration_Chaining/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/Durable/Agents/AzureFunctions/01_SingleAgent/Program.cs | Updated conditional to use DefaultAzureCredential with warning comment |
| dotnet/samples/AGUIWebChat/Server/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/AGUIClientServer/AGUIServer/Program.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/AGUIClientServer/AGUIDojoServer/ChatClientAgentFactory.cs | Updated to use DefaultAzureCredential with warning comment |
| dotnet/samples/A2AClientServer/A2AServer/HostAgentFactory.cs | Updated to use DefaultAzureCredential with warning comment |
Motivation and Context
Related item: #795