-
Notifications
You must be signed in to change notification settings - Fork 184
Add app config and related feature flag capabilities #87
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
Open
aprilk-ms
wants to merge
33
commits into
Azure-Samples:main
Choose a base branch
from
aprilk-ms:aprilk/add-exp-clean
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
7af05c8
make deployable
aprilk-ms b399a51
minimal updates
aprilk-ms 0f456b4
Merge branch 'main' into aprilk/add-exp
aprilk-ms bb08f51
remove vscode settings
aprilk-ms 371b4c3
add to .gitignore
aprilk-ms c2b3b63
Work in progress
aprilk-ms 19abd4c
Configure Azure Developer Pipeline
aprilk-ms ba41c7c
add empty feature flag file
aprilk-ms c96b5f3
Update workflow name
aprilk-ms 3fe9f12
start a feature flag
aprilk-ms e4e1de1
minor updates
aprilk-ms f8bb98c
Add variant to message title
aprilk-ms 0616a36
Added new thread button
aprilk-ms 7fe4ce1
update icon and use thread id for randomization
aprilk-ms cd2e117
Some cleanup
aprilk-ms bc4981b
clean up for PR
aprilk-ms 7466a59
Minor fixes
aprilk-ms dc5f9ec
minor fixes
aprilk-ms 7f3c217
Configure Azure Developer Pipeline
aprilk-ms 8e10baa
update deploy workflow
aprilk-ms 968db30
Update title
aprilk-ms b34f52c
back to short name
aprilk-ms 4d8c058
fixed bicep
aprilk-ms c880263
update feature flags
aprilk-ms d78639d
minor fixes to app config initialize
aprilk-ms f32ea57
fix bicep and address some feedbacks
aprilk-ms 27d3a59
addressed feedback and minor updates
aprilk-ms 94d9ffe
update
aprilk-ms 5c847fd
update to async
aprilk-ms dc4e590
Merge branch 'main' into aprilk/add-exp
aprilk-ms 027181d
update with new UX
aprilk-ms a989dbc
Merge with new UX updates
aprilk-ms 5d26938
Revert registry changes
aprilk-ms File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"schemaVersion": "2.0.0", | ||
"feature_management": { | ||
"feature_flags": [ | ||
] | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"schemaVersion": "2.0.0", | ||
"feature_management": { | ||
"feature_flags": [ | ||
{ | ||
"id": "my-agent", | ||
"enabled": true, | ||
"variants": [ | ||
{ | ||
"name": "agent_v1", | ||
"configuration_value": "<agent-id-1-placeholder>" | ||
}, | ||
{ | ||
"name": "agent_v2", | ||
"configuration_value": "<agent-id-2-placeholder>" | ||
} | ||
], | ||
"allocation": { | ||
"percentile": [ | ||
{ | ||
"variant": "agent_v1", | ||
"from": 0, | ||
"to": 50 | ||
}, | ||
{ | ||
"variant": "agent_v2", | ||
"from": 50, | ||
"to": 100 | ||
} | ||
], | ||
"default_when_enabled": "agent_v1", | ||
"default_when_disabled": "agent_v1" | ||
}, | ||
"telemetry": { | ||
"enabled": true | ||
} | ||
} | ||
] | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Validate Experiments | ||
on: | ||
workflow_dispatch: | ||
|
||
# GitHub Actions workflow to deploy to Azure using azd | ||
# To configure required secrets for connecting to Azure, simply run `azd pipeline config` | ||
|
||
# Set up permissions for deploying with secretless Azure federated credentials | ||
# https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux#set-up-azure-login-with-openid-connect-authentication | ||
permissions: | ||
id-token: write | ||
contents: read | ||
|
||
env: | ||
APP_CONFIGURATION_FILE: .config/feature-flags.json | ||
|
||
jobs: | ||
validate-feature-flags: | ||
name: Validate Feature Flags | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Validate App Config feature flags | ||
uses: azure/app-configuration-deploy-feature-flags@v1-beta | ||
with: | ||
path: ${{ env.APP_CONFIGURATION_FILE }} | ||
operation: validate | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ ENV/ | |
env.bak/ | ||
venv.bak/ | ||
.azure | ||
.vscode/ |
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
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
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
This file was deleted.
Oops, something went wrong.
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,8 +50,31 @@ async def lifespan(app: fastapi.FastAPI): | |
else: | ||
from azure.monitor.opentelemetry import configure_azure_monitor | ||
configure_azure_monitor(connection_string=application_insights_connection_string) | ||
# Do not instrument the code yet, before trace fix is available. | ||
#ai_client.telemetry.enable() | ||
ai_client.telemetry.enable() | ||
logger.info("Configured Application Insights for tracing.") | ||
|
||
app_config_endpoint = os.getenv("APP_CONFIGURATION_ENDPOINT") | ||
if app_config_endpoint: | ||
try: | ||
from azure.appconfiguration.provider.aio import load | ||
from featuremanagement.aio import FeatureManager | ||
from featuremanagement.azuremonitor import publish_telemetry | ||
app_config = await load( | ||
endpoint=app_config_endpoint, | ||
credential=DefaultAzureCredential(), | ||
feature_flag_enabled=True, | ||
feature_flag_refresh_enabled=True, | ||
refresh_interval=300 # no refresh within 5 mins to avoid throttling | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: update to 2 mins |
||
) | ||
feature_manager = FeatureManager(app_config, on_feature_evaluated=publish_telemetry) | ||
app.state.app_config = app_config | ||
app.state.feature_manager = feature_manager | ||
logger.info("Configured App Configuration with feature flag support.") | ||
except ModuleNotFoundError: | ||
logger.warning("Required libraries for App Configuration not installed.") | ||
logger.warning("Please make sure azure-appconfiguration-provider and FeatureManagement are installed.") | ||
except Exception as e: | ||
logger.warning("Failed to setup App Configuration", exc_info=True) | ||
|
||
if agent_id: | ||
try: | ||
|
Oops, something went wrong.
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.
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.
If you remove newGUID, it might break AI Search resource creation.