-
Notifications
You must be signed in to change notification settings - Fork 3.2k
App Config Fixing + Adding Samples #44790
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5dd10b7
Fixing/Adding samples
mrm9084 a7c9752
Merge remote-tracking branch 'upstream/main' into FixSamples
mrm9084 c0d9269
Apply suggestion from @Copilot
mrm9084 62f3f79
Apply suggestion from @Copilot
mrm9084 06c56b2
Apply suggestions from code review
mrm9084 91dc37f
Update README.md
mrm9084 facce70
Merge branch 'main' into FixSamples
mrm9084 bea9f28
Merge branch 'FixSamples' of https://github.com/mrm9084/azure-sdk-for…
mrm9084 37ce394
removing fail as we create the keys
mrm9084 ed79ded
fixing test mypy issue
mrm9084 9a3d0d4
update tests
mrm9084 f7acc2f
fixing sample
mrm9084 24d4f17
format fixes
mrm9084 68230d8
Fixing sample + disable one live test
mrm9084 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
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
70 changes: 70 additions & 0 deletions
70
sdk/appconfiguration/azure-appconfiguration/samples/hello_world_entra_id_sample.py
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,70 @@ | ||
| # coding: utf-8 | ||
|
|
||
| # ------------------------------------------------------------------------- | ||
| # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # Licensed under the MIT License. See License.txt in the project root for | ||
| # license information. | ||
| # -------------------------------------------------------------------------- | ||
|
|
||
| """ | ||
| FILE: hello_world_entra_id_sample.py | ||
|
|
||
| DESCRIPTION: | ||
| This sample demos how to add/update/retrieve/delete configuration settings synchronously. | ||
|
|
||
| USAGE: python hello_world_entra_id_sample.py | ||
|
|
||
| Set the environment variables with your own values before running the sample: | ||
| 1) APPCONFIGURATION_CONNECTION_STRING: Connection String used to access the Azure App Configuration. | ||
| """ | ||
| import os | ||
| from azure.appconfiguration import AzureAppConfigurationClient | ||
| from azure.identity import DefaultAzureCredential | ||
| from azure.appconfiguration import ConfigurationSetting | ||
|
|
||
|
|
||
| def main(): | ||
| # [START create_app_config_client] | ||
|
|
||
| ENDPOINT = os.environ["APPCONFIGURATION_ENDPOINT"] | ||
| credential = DefaultAzureCredential() | ||
| # Create app config client | ||
| client = AzureAppConfigurationClient(base_url=ENDPOINT, credential=credential) | ||
| # [END create_app_config_client] | ||
|
|
||
| print("Add new configuration setting") | ||
| # [START create_config_setting] | ||
| config_setting = ConfigurationSetting( | ||
| key="MyKey", label="MyLabel", value="my value", content_type="my content type", tags={"my tag": "my tag value"} | ||
| ) | ||
| added_config_setting = client.add_configuration_setting(config_setting) | ||
| # [END create_config_setting] | ||
| print("New configuration setting:") | ||
| print(added_config_setting) | ||
| print("") | ||
|
|
||
| print("Set configuration setting") | ||
| # [START set_config_setting] | ||
| added_config_setting.value = "new value" | ||
| added_config_setting.content_type = "new content type" | ||
| updated_config_setting = client.set_configuration_setting(added_config_setting) | ||
| # [END set_config_setting] | ||
| print(updated_config_setting) | ||
| print("") | ||
|
|
||
| print("Get configuration setting") | ||
| # [START get_config_setting] | ||
| fetched_config_setting = client.get_configuration_setting(key="MyKey", label="MyLabel") | ||
| # [END get_config_setting] | ||
| print("Fetched configuration setting:") | ||
| print(fetched_config_setting) | ||
| print("") | ||
|
|
||
| print("Delete configuration setting") | ||
| # [START delete_config_setting] | ||
| client.delete_configuration_setting(key="MyKey", label="MyLabel") | ||
| # [END delete_config_setting] | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
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.
Uh oh!
There was an error while loading. Please reload this page.