Skip to content
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

Azure App Configuration Provider Beta #26016

Merged
merged 137 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
0b71864
Adding azure-appconfiguration-provider
mrm9084 Aug 30, 2022
95e8f80
Fixing repo issue
mrm9084 Aug 30, 2022
7085b93
Fixing repo issue
mrm9084 Aug 30, 2022
2c49e9d
Updated to setup user agent and header info
mrm9084 Aug 30, 2022
c6895e9
Updating to cache secret_clients
mrm9084 Aug 30, 2022
9f1cc57
Fixed Naming
mrm9084 Aug 30, 2022
9a86e7b
Fixed Typo
mrm9084 Aug 30, 2022
5e3d409
Added Samples, Fixed issue with Key Vault Options not set when secret…
mrm9084 Sep 1, 2022
6ac7714
Fixed SP, Dependency, and Pylint issues
mrm9084 Sep 2, 2022
649e6fd
Fixed more lint issues, moved key vault references to be a method
mrm9084 Sep 2, 2022
ffd2d62
More Linting fixes
mrm9084 Sep 2, 2022
84dd770
Fixing dependency issues with build
mrm9084 Sep 2, 2022
31d2318
Updated Docs. Fixed extra code for Key Vault Usage. Updated Readme to…
mrm9084 Sep 9, 2022
0aa7e99
Adding Test Case, currently doesn't work
mrm9084 Sep 9, 2022
0aa91a5
Fixing Tests
mrm9084 Sep 19, 2022
68e20d7
Fixing Trim. Fixing Typo in readme.
mrm9084 Sep 19, 2022
7ca6cd3
Fixing Length and vault_url issues.
mrm9084 Sep 19, 2022
2c8bb78
Updating from code review comments
mrm9084 Sep 20, 2022
f7e3929
Added more error checking. Made Key_VAULT_SECRET_PREFIX a constant.
mrm9084 Sep 20, 2022
ef7a7f5
Updated to use Key Vault Identifier.
mrm9084 Sep 20, 2022
cbf2acb
Fixed Spelling
mrm9084 Sep 20, 2022
047d526
Updated Test
mrm9084 Sep 20, 2022
f379833
Reworked key vault reference resolution. Fixed lint issues.
mrm9084 Sep 20, 2022
dcb6cf7
Fixing Lint Issue. Updating Test Running
mrm9084 Sep 21, 2022
a0c6cb8
Fixing Tests
mrm9084 Sep 21, 2022
4dd0831
Fixed Tests?
mrm9084 Sep 21, 2022
d7ae7dd
Setting secret clients to {} if none. Adding override to shared_requi…
mrm9084 Sep 21, 2022
ce5863f
Merge branch 'Azure:main' into main
mrm9084 Sep 21, 2022
17b46ba
Merge branch 'main' of github.com:mrm9084/azure-sdk-for-python
mrm9084 Sep 21, 2022
3dcb5d4
Updating shared requirements
mrm9084 Sep 21, 2022
821cd09
Fixed override. Switched to SecretReferenceConfigurationSetting
mrm9084 Sep 21, 2022
22a7716
Updated Requirement KeyVaultSecretIdentifier is needed.
mrm9084 Sep 21, 2022
f67503c
Update ci.yml
mrm9084 Sep 21, 2022
34f274d
Update ci.yml
mrm9084 Sep 21, 2022
ceab535
Fixed structure
mrm9084 Sep 22, 2022
d9e75a6
Update dev_requirements.txt
mrm9084 Sep 22, 2022
8407fbc
Update sdk_packaging.toml
mrm9084 Sep 22, 2022
6ce62f5
Revert working state
mrm9084 Sep 22, 2022
95e5d30
Renamed correctly
mrm9084 Sep 22, 2022
1002b68
Merge branch 'main' into main
mrm9084 Sep 22, 2022
fdc6e98
Using azure-appconfigurationprovider
mrm9084 Sep 22, 2022
2e390e9
Merge branch 'main' of github.com:mrm9084/azure-sdk-for-python
mrm9084 Sep 22, 2022
e6d65fb
Fixing shared Requirements merge issue
mrm9084 Sep 22, 2022
4a6b17c
Updated from review comments
mrm9084 Sep 23, 2022
76c4fb9
Fixing package folder
mrm9084 Sep 23, 2022
5c2d30e
Fix lint, removed extra fixture
mrm9084 Sep 23, 2022
9171668
Create py.typed
mrm9084 Sep 23, 2022
f81281c
Updated Manifest to use right py.typed file
mrm9084 Sep 23, 2022
740ba65
Switched Files
mrm9084 Sep 23, 2022
7a436aa
Fixing lint issue
mrm9084 Sep 23, 2022
3d0a7e9
Setting defaults for test
mrm9084 Sep 24, 2022
b8faf09
Updating Docs
mrm9084 Sep 26, 2022
8efbc43
Fixing Whitespace
mrm9084 Sep 26, 2022
b2cc043
Updating to support in operation
mrm9084 Sep 26, 2022
e6619bd
Updated sample with in usage
mrm9084 Sep 26, 2022
176673a
Cleaned up key trimming usage
mrm9084 Sep 26, 2022
dfd6fac
Removed extra catches for now. Cleaned up lint.
mrm9084 Sep 27, 2022
b2bfbff
Adding more tests
mrm9084 Sep 27, 2022
75bc7e2
Fixed Linting
mrm9084 Sep 28, 2022
9639c96
Fixing Auto Format
mrm9084 Sep 29, 2022
2f07a55
Fixing Key Vault Reference Test
mrm9084 Oct 6, 2022
560be04
Trying to update the package name
mrm9084 Oct 6, 2022
f340a5e
Fixed formatting?
mrm9084 Oct 6, 2022
dc943c3
Adding azure-appconfiguration-provider
mrm9084 Aug 30, 2022
e8dec63
Fixing repo issue
mrm9084 Aug 30, 2022
9e889d0
Fixing repo issue
mrm9084 Aug 30, 2022
c3b56e5
Updated to setup user agent and header info
mrm9084 Aug 30, 2022
86cd913
Updating to cache secret_clients
mrm9084 Aug 30, 2022
1220f9d
Fixed Naming
mrm9084 Aug 30, 2022
9e48429
Fixed Typo
mrm9084 Aug 30, 2022
0b15d1a
Added Samples, Fixed issue with Key Vault Options not set when secret…
mrm9084 Sep 1, 2022
8aa4762
Fixed SP, Dependency, and Pylint issues
mrm9084 Sep 2, 2022
4fdfb56
Fixed more lint issues, moved key vault references to be a method
mrm9084 Sep 2, 2022
b87beee
More Linting fixes
mrm9084 Sep 2, 2022
b237292
Fixing dependency issues with build
mrm9084 Sep 2, 2022
8335a1a
Updated Docs. Fixed extra code for Key Vault Usage. Updated Readme to…
mrm9084 Sep 9, 2022
b097b0f
Adding Test Case, currently doesn't work
mrm9084 Sep 9, 2022
1f57085
Fixing Tests
mrm9084 Sep 19, 2022
2bd138e
Fixing Trim. Fixing Typo in readme.
mrm9084 Sep 19, 2022
14487de
Fixing Length and vault_url issues.
mrm9084 Sep 19, 2022
262ba3d
Updating from code review comments
mrm9084 Sep 20, 2022
8dec35a
Added more error checking. Made Key_VAULT_SECRET_PREFIX a constant.
mrm9084 Sep 20, 2022
cd5af67
Updated to use Key Vault Identifier.
mrm9084 Sep 20, 2022
5c888b4
Fixed Spelling
mrm9084 Sep 20, 2022
689487f
Updated Test
mrm9084 Sep 20, 2022
9f0d7c7
Reworked key vault reference resolution. Fixed lint issues.
mrm9084 Sep 20, 2022
4e977ae
Fixing Lint Issue. Updating Test Running
mrm9084 Sep 21, 2022
9d0b579
Fixing Tests
mrm9084 Sep 21, 2022
47127bf
Fixed Tests?
mrm9084 Sep 21, 2022
5aa01d1
Setting secret clients to {} if none. Adding override to shared_requi…
mrm9084 Sep 21, 2022
cb71779
Updating shared requirements
mrm9084 Sep 21, 2022
ac8aa14
Fixed override. Switched to SecretReferenceConfigurationSetting
mrm9084 Sep 21, 2022
6590ae3
Updated Requirement KeyVaultSecretIdentifier is needed.
mrm9084 Sep 21, 2022
0fdaab5
Update ci.yml
mrm9084 Sep 21, 2022
a325123
Update ci.yml
mrm9084 Sep 21, 2022
ffa7a78
Fixed structure
mrm9084 Sep 22, 2022
87cf458
Update dev_requirements.txt
mrm9084 Sep 22, 2022
fe5944f
Update sdk_packaging.toml
mrm9084 Sep 22, 2022
bc9e941
Revert working state
mrm9084 Sep 22, 2022
f776454
Renamed correctly
mrm9084 Sep 22, 2022
d585fcd
Using azure-appconfigurationprovider
mrm9084 Sep 22, 2022
5a3f340
Fixing shared Requirements merge issue
mrm9084 Sep 22, 2022
4af6180
Updated from review comments
mrm9084 Sep 23, 2022
20937c8
Fixing package folder
mrm9084 Sep 23, 2022
6ea9f72
Fix lint, removed extra fixture
mrm9084 Sep 23, 2022
3157ec4
Create py.typed
mrm9084 Sep 23, 2022
e967499
Updated Manifest to use right py.typed file
mrm9084 Sep 23, 2022
c98f1f8
Switched Files
mrm9084 Sep 23, 2022
c794d46
Fixing lint issue
mrm9084 Sep 23, 2022
39eacba
Setting defaults for test
mrm9084 Sep 24, 2022
23d6fb9
Updating Docs
mrm9084 Sep 26, 2022
8c4bc04
Fixing Whitespace
mrm9084 Sep 26, 2022
9b33797
Updating to support in operation
mrm9084 Sep 26, 2022
682bd2c
Updated sample with in usage
mrm9084 Sep 26, 2022
22636cd
Cleaned up key trimming usage
mrm9084 Sep 26, 2022
784ffee
Removed extra catches for now. Cleaned up lint.
mrm9084 Sep 27, 2022
1bedd5a
Adding more tests
mrm9084 Sep 27, 2022
d28b57e
Fixed Linting
mrm9084 Sep 28, 2022
9da907d
Fixing Auto Format
mrm9084 Sep 29, 2022
f46b1ab
Fixing Key Vault Reference Test
mrm9084 Oct 6, 2022
a1feea8
Trying to update the package name
mrm9084 Oct 6, 2022
a807121
Merge branch 'main' of github.com:mrm9084/azure-sdk-for-python
mrm9084 Oct 6, 2022
abcd3d8
Merge branch 'Azure:main' into main
mrm9084 Oct 6, 2022
e1bd5b4
Removing Extra TestProxy
mrm9084 Oct 6, 2022
16c3795
Not -e installing azure-appconfiguration
mrm9084 Oct 6, 2022
acf1b9c
updates
xiangyan99 Oct 6, 2022
bea39b8
update
xiangyan99 Oct 6, 2022
9aea9e4
update
xiangyan99 Oct 6, 2022
601470f
Update sdk/appconfiguration/azure-appconfiguration-provider/setup.py
xiangyan99 Oct 7, 2022
b515416
update
xiangyan99 Oct 7, 2022
bf82613
Merge branch 'main' of https://github.com/mrm9084/azure-sdk-for-python
xiangyan99 Oct 7, 2022
5802867
Updated min version of app config
mrm9084 Oct 11, 2022
3290b6f
Updating sanitizer
mrm9084 Oct 12, 2022
b232b93
Merge branch 'main' of github.com:mrm9084/azure-sdk-for-python
mrm9084 Oct 12, 2022
16cabad
Updating Shared Requirement
mrm9084 Oct 12, 2022
fb4bc3a
Temp removing key vault test
mrm9084 Oct 12, 2022
7404333
Removing actual tests
mrm9084 Oct 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Release History

## 1.0.0b1 (Unreleased)

New Azure App Configuration Provider

Provides additional support above the Azure App Configuration SDK. Enables:
* Connecting to an Azure App Configuration store
* Selecting multiple keys using Setting Selector
* Resolve Key Vault References when supplied AzureAppConfigurationKeyVaultOptions

The Azure App Configuration Provider once loaded returns a dictionary of key/value pairs to use in configuration.

```python
endpoint = "https://<your-store>.azconfig.io"
default_credential = DefaultAzureCredential()
config = AzureAppConfigurationProvider.load(
endpoint=endpoint, credential=default_credential)
print(config["message"])
```
21 changes: 21 additions & 0 deletions sdk/appconfiguration/azure-appconfiguration-provider/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Copyright (c) Microsoft Corporation.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
recursive-include tests *.py
include *.md
include LICENSE
include azure/__init__.py
recursive-include samples *.py *.md
recursive-include doc *.rst
include azure/appconfiguration/py.typed
mrm9084 marked this conversation as resolved.
Show resolved Hide resolved
141 changes: 141 additions & 0 deletions sdk/appconfiguration/azure-appconfiguration-provider/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Azure App Configuration Python Provider client library for Python

Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely. This provider adds additional functionality above the azure-sdk-for-python.

Using the provider enables loading sets of configurations from a Azure App Configuration store in a managed way.
mrm9084 marked this conversation as resolved.
Show resolved Hide resolved

## Getting started

### Get credentials

Use the [Azure CLI][azure_cli] snippet below to get the connection string from the Configuration Store.

```Powershell
az appconfig credential list --name <config-store-name>
```

Alternatively, get the connection string from the Azure Portal.

### Creating a provider

You can create a client with a connection string:

```python
config = AzureAppConfigurationProvider.load(connection_string="your-connection-string")
```

or with AAD:

```python
config = AzureAppConfigurationProvider.load(endpoint="your-endpoint", credential=DefaultAzureCredential())
```

these providers will by default load all configurations with `(No Label)` from your configuration store.

### Features

Currently the Azure App Configuration Provider enables:

* Connecting to an App Configuration Store using a connection string or Azure Active Directory.
* Selecting multiple sets of configurations using `SettingSelector`.
* Trim prefixes off key names.
* Resolving Key Vault References, requires AAD.
* Secret Resolver, resolve Key Vault References locally without connecting to Key Vault.
* Json Content Type

#### Future Features

List of features we are going to add to the Python Provider in the future.

* Geo-Replication support
* Feature Management
* Dynamic Refresh
* Configuration Placeholders

## Examples

### Selecting configurations

You can refine or expand the configurations loaded from your store by using `SettingSelector`s. Setting selectors provide a way to pass a key filter and label filter into the provider.

```python
selects = {SettingSelector(key_filter="*", label_filter="\0"), SettingSelector(key_filter="*", label_filter="dev")}
config = AzureAppConfigurationProvider.load(
endpoint=endpoint, credential=default_credential, selects=selects)
```
In this example all configuration with empty label and the dev label are loaded. Because the dev selector is listed last, any configurations from dev take priority over those with `(No Label)` when duplicates are found.

### Trimming Keys

You can trim the prefix off of keys by providing a list of trimmed key prefixes to the provider.

```python
trimmed_key_prefixes={"/application/"}
config = AzureAppConfigurationProvider.load(
endpoint=endpoint, credential=default_credential, trimmed_key_prefixes=trimmed_key_prefixes)
```
mrm9084 marked this conversation as resolved.
Show resolved Hide resolved

### Resolving Key Vault References

Key Vault References can be resolved by providing credentials to your key vault to the provider using `AzureAppConfigurationKeyVaultOptions`.

#### With Credentials

You can provide `AzureAppConfigurationKeyVaultOptions` with a credential and all key vault references will be resolved with it. The provider will attempt to connect to any key vault referenced with the credential provided.

```python
key_vault_options = AzureAppConfigurationKeyVaultOptions(credential=default_credential)
config = AzureAppConfigurationProvider.load(endpoint=endpoint, credential=default_credential, key_vault_options=key_vault_options)
```
### With Clients

You can provide `AzureAppConfigurationKeyVaultOptions` with a list of `SecretClients`.

```python
key_vault_options = AzureAppConfigurationKeyVaultOptions(
secret_clients={SecretClient(
vault_url=key_vault_uri, credential=default_credential)})
config = AzureAppConfigurationProvider.load(endpoint=endpoint, credential=default_credential, key_vault_options=key_vault_options)
```

### Secret Resolver

If no Credentials or Clients are provided a secret resolver can be used. Secret resolver provides a way to return any value you want to a key vault reference.

```python
def secret_resolver(uri):
return "From Secret Resolver"

key_vault_options = AzureAppConfigurationKeyVaultOptions(
secret_resolver=secret_resolver)
config = AzureAppConfigurationProvider.load(
endpoint=endpoint, credential=default_credential, key_vault_options=key_vault_options)
```

## Key concepts

## Troubleshooting

## Next steps

## Contributing

This project welcomes contributions and suggestions. Most contributions require
you to agree to a Contributor License Agreement (CLA) declaring that you have
the right to, and actually do, grant us the rights to use your contribution.
For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether
you need to provide a CLA and decorate the PR appropriately (e.g., label,
comment). Simply follow the instructions provided by the bot. You will only
need to do this once across all repos using our CLA.

This project has adopted the
[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
see the Code of Conduct FAQ or contact [email protected] with any
additional questions or comments.

[cla]: https://cla.microsoft.com
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/
[coc_contact]: mailto:[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__path__ = __import__("pkgutil").extend_path(
__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# ------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# -------------------------------------------------------------------------

from ._azureappconfigurationprovider import AzureAppConfigurationProvider
from ._azureappconfigurationkeyvaultoptions import AzureAppConfigurationKeyVaultOptions
from ._settingselector import SettingSelector

from ._version import VERSION

__version__ = VERSION
__all__ = [
"AzureAppConfigurationProvider",
"AzureAppConfigurationKeyVaultOptions",
"SettingSelector"
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# ------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# -------------------------------------------------------------------------

class AzureAppConfigurationKeyVaultOptions:
"""
Options for connecting to Key Vault.
:param credential: A credential for authenticating with the key vault. This is optional if secret_clients is provided.
:type credential: ~azure.core.credentials.TokenCredential
:param secret_clients: A list of SecretClient from azure-keyvault-secrets. This is optional if credential is provided.
:type secret_clients: list[~azure.keyvault.secrets.SecretClient]
:param secret_resolver: A function that takes a URI and returns a value.
:type secret_resolver: callable
"""

def __init__(self, credential=None, secret_clients=None, secret_resolver=None):
# type: (TokenCredential, List[SecretClient], Callable) -> None
self.credential = credential
self.secret_clients = secret_clients
self.secret_resolver = secret_resolver
Loading