Fixing issue with test sample for FastAPI#458
Draft
rodrigobr-msft wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the FastAPI “empty agent” test sample to initialize the agent using environment-based configuration and MSAL authentication, and to wire JWT-based authorization into the FastAPI host so requests can be authorized consistently.
Changes:
- Load agent configuration from environment variables (with dotenv support) and construct shared SDK components (storage, MSAL connection manager, adapter, authorization).
- Update
AgentApplicationinitialization to use the new configuration/authentication components. - Add/update JWT authorization middleware wiring and app configuration setup for FastAPI.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+6
to
+8
| from dotenv import load_dotenv | ||
|
|
||
| from os import environ |
Comment on lines
81
to
+86
| if __name__ == "__main__": | ||
| import os | ||
|
|
||
| app.state.agent_configuration = (CONNECTION_MANAGER.get_default_connection_configuration()) | ||
| app.add_middleware(JwtAuthorizationMiddleware) | ||
|
|
||
| port = int(os.environ.get("PORT", 3978)) | ||
| port = int(environ.get("PORT", 3978)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors the FastAPI sample agent to improve configuration management, authentication, and application setup. The main changes include loading configuration from environment variables, integrating MSAL-based authentication, and updating how the agent application and FastAPI app are initialized.
Configuration and Authentication Improvements:
dotenvintegration andload_configuration_from_envto load agent configuration from environment variables, making the setup more flexible and secure.MsalConnectionManagerand updated the agent to use MSAL-based authentication, enabling better support for secure connections.AuthorizationandJwtAuthorizationMiddlewareto the FastAPI app for improved authorization handling. [1] [2]Application Initialization Updates: