feat: Add Official Microsoft & Gemini Skills (845+ Total)
🚀 Impact Significantly expands the capabilities of **Antigravity Awesome Skills** by integrating official skill collections from **Microsoft** and **Google Gemini**. This update increases the total skill count to **845+**, making the library even more comprehensive for AI coding assistants. ✨ Key Changes 1. New Official Skills - **Microsoft Skills**: Added a massive collection of official skills from [microsoft/skills](https://github.com/microsoft/skills). - Includes Azure, .NET, Python, TypeScript, and Semantic Kernel skills. - Preserves the original directory structure under `skills/official/microsoft/`. - Includes plugin skills from the `.github/plugins` directory. - **Gemini Skills**: Added official Gemini API development skills under `skills/gemini-api-dev/`. 2. New Scripts & Tooling - **`scripts/sync_microsoft_skills.py`**: A robust synchronization script that: - Clones the official Microsoft repository. - Preserves the original directory heirarchy. - Handles symlinks and plugin locations. - Generates attribution metadata. - **`scripts/tests/inspect_microsoft_repo.py`**: Debug tool to inspect the remote repository structure. - **`scripts/tests/test_comprehensive_coverage.py`**: Verification script to ensure 100% of skills are captured during sync. 3. Core Improvements - **`scripts/generate_index.py`**: Enhanced frontmatter parsing to safely handle unquoted values containing `@` symbols and commas (fixing issues with some Microsoft skill descriptions). - **`package.json`**: Added `sync:microsoft` and `sync:all-official` scripts for easy maintenance. 4. Documentation - Updated `README.md` to reflect the new skill counts (845+) and added Microsoft/Gemini to the provider list. - Updated `CATALOG.md` and `skills_index.json` with the new skills. 🧪 Verification - Ran `scripts/tests/test_comprehensive_coverage.py` to verify all Microsoft skills are detected. - Validated `generate_index.py` fixes by successfully indexing the new skills.
This commit is contained in:
242
skills/official/microsoft/python/integration/apicenter/SKILL.md
Normal file
242
skills/official/microsoft/python/integration/apicenter/SKILL.md
Normal file
@@ -0,0 +1,242 @@
|
||||
---
|
||||
name: azure-mgmt-apicenter-py
|
||||
description: |
|
||||
Azure API Center Management SDK for Python. Use for managing API inventory, metadata, and governance across your organization.
|
||||
Triggers: "azure-mgmt-apicenter", "ApiCenterMgmtClient", "API Center", "API inventory", "API governance".
|
||||
package: azure-mgmt-apicenter
|
||||
---
|
||||
|
||||
# Azure API Center Management SDK for Python
|
||||
|
||||
Manage API inventory, metadata, and governance in Azure API Center.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install azure-mgmt-apicenter
|
||||
pip install azure-identity
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
```bash
|
||||
AZURE_SUBSCRIPTION_ID=your-subscription-id
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
```python
|
||||
from azure.identity import DefaultAzureCredential
|
||||
from azure.mgmt.apicenter import ApiCenterMgmtClient
|
||||
import os
|
||||
|
||||
client = ApiCenterMgmtClient(
|
||||
credential=DefaultAzureCredential(),
|
||||
subscription_id=os.environ["AZURE_SUBSCRIPTION_ID"]
|
||||
)
|
||||
```
|
||||
|
||||
## Create API Center
|
||||
|
||||
```python
|
||||
from azure.mgmt.apicenter.models import Service
|
||||
|
||||
api_center = client.services.create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-api-center",
|
||||
resource=Service(
|
||||
location="eastus",
|
||||
tags={"environment": "production"}
|
||||
)
|
||||
)
|
||||
|
||||
print(f"Created API Center: {api_center.name}")
|
||||
```
|
||||
|
||||
## List API Centers
|
||||
|
||||
```python
|
||||
api_centers = client.services.list_by_subscription()
|
||||
|
||||
for api_center in api_centers:
|
||||
print(f"{api_center.name} - {api_center.location}")
|
||||
```
|
||||
|
||||
## Register an API
|
||||
|
||||
```python
|
||||
from azure.mgmt.apicenter.models import Api, ApiKind, LifecycleStage
|
||||
|
||||
api = client.apis.create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-api-center",
|
||||
workspace_name="default",
|
||||
api_name="my-api",
|
||||
resource=Api(
|
||||
title="My API",
|
||||
description="A sample API for demonstration",
|
||||
kind=ApiKind.REST,
|
||||
lifecycle_stage=LifecycleStage.PRODUCTION,
|
||||
terms_of_service={"url": "https://example.com/terms"},
|
||||
contacts=[{"name": "API Team", "email": "api-team@example.com"}]
|
||||
)
|
||||
)
|
||||
|
||||
print(f"Registered API: {api.title}")
|
||||
```
|
||||
|
||||
## Create API Version
|
||||
|
||||
```python
|
||||
from azure.mgmt.apicenter.models import ApiVersion, LifecycleStage
|
||||
|
||||
version = client.api_versions.create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-api-center",
|
||||
workspace_name="default",
|
||||
api_name="my-api",
|
||||
version_name="v1",
|
||||
resource=ApiVersion(
|
||||
title="Version 1.0",
|
||||
lifecycle_stage=LifecycleStage.PRODUCTION
|
||||
)
|
||||
)
|
||||
|
||||
print(f"Created version: {version.title}")
|
||||
```
|
||||
|
||||
## Add API Definition
|
||||
|
||||
```python
|
||||
from azure.mgmt.apicenter.models import ApiDefinition
|
||||
|
||||
definition = client.api_definitions.create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-api-center",
|
||||
workspace_name="default",
|
||||
api_name="my-api",
|
||||
version_name="v1",
|
||||
definition_name="openapi",
|
||||
resource=ApiDefinition(
|
||||
title="OpenAPI Definition",
|
||||
description="OpenAPI 3.0 specification"
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
## Import API Specification
|
||||
|
||||
```python
|
||||
from azure.mgmt.apicenter.models import ApiSpecImportRequest, ApiSpecImportSourceFormat
|
||||
|
||||
# Import from inline content
|
||||
client.api_definitions.import_specification(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-api-center",
|
||||
workspace_name="default",
|
||||
api_name="my-api",
|
||||
version_name="v1",
|
||||
definition_name="openapi",
|
||||
body=ApiSpecImportRequest(
|
||||
format=ApiSpecImportSourceFormat.INLINE,
|
||||
value='{"openapi": "3.0.0", "info": {"title": "My API", "version": "1.0"}, "paths": {}}'
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
## List APIs
|
||||
|
||||
```python
|
||||
apis = client.apis.list(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-api-center",
|
||||
workspace_name="default"
|
||||
)
|
||||
|
||||
for api in apis:
|
||||
print(f"{api.name}: {api.title} ({api.kind})")
|
||||
```
|
||||
|
||||
## Create Environment
|
||||
|
||||
```python
|
||||
from azure.mgmt.apicenter.models import Environment, EnvironmentKind
|
||||
|
||||
environment = client.environments.create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-api-center",
|
||||
workspace_name="default",
|
||||
environment_name="production",
|
||||
resource=Environment(
|
||||
title="Production",
|
||||
description="Production environment",
|
||||
kind=EnvironmentKind.PRODUCTION,
|
||||
server={"type": "Azure API Management", "management_portal_uri": ["https://portal.azure.com"]}
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
## Create Deployment
|
||||
|
||||
```python
|
||||
from azure.mgmt.apicenter.models import Deployment, DeploymentState
|
||||
|
||||
deployment = client.deployments.create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-api-center",
|
||||
workspace_name="default",
|
||||
api_name="my-api",
|
||||
deployment_name="prod-deployment",
|
||||
resource=Deployment(
|
||||
title="Production Deployment",
|
||||
description="Deployed to production APIM",
|
||||
environment_id="/workspaces/default/environments/production",
|
||||
definition_id="/workspaces/default/apis/my-api/versions/v1/definitions/openapi",
|
||||
state=DeploymentState.ACTIVE,
|
||||
server={"runtime_uri": ["https://api.example.com"]}
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
## Define Custom Metadata
|
||||
|
||||
```python
|
||||
from azure.mgmt.apicenter.models import MetadataSchema
|
||||
|
||||
metadata = client.metadata_schemas.create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-api-center",
|
||||
metadata_schema_name="data-classification",
|
||||
resource=MetadataSchema(
|
||||
schema='{"type": "string", "title": "Data Classification", "enum": ["public", "internal", "confidential"]}'
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
## Client Types
|
||||
|
||||
| Client | Purpose |
|
||||
|--------|---------|
|
||||
| `ApiCenterMgmtClient` | Main client for all operations |
|
||||
|
||||
## Operations
|
||||
|
||||
| Operation Group | Purpose |
|
||||
|----------------|---------|
|
||||
| `services` | API Center service management |
|
||||
| `workspaces` | Workspace management |
|
||||
| `apis` | API registration and management |
|
||||
| `api_versions` | API version management |
|
||||
| `api_definitions` | API definition management |
|
||||
| `deployments` | Deployment tracking |
|
||||
| `environments` | Environment management |
|
||||
| `metadata_schemas` | Custom metadata definitions |
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use workspaces** to organize APIs by team or domain
|
||||
2. **Define metadata schemas** for consistent governance
|
||||
3. **Track deployments** to understand where APIs are running
|
||||
4. **Import specifications** to enable API analysis and linting
|
||||
5. **Use lifecycle stages** to track API maturity
|
||||
6. **Add contacts** for API ownership and support
|
||||
@@ -0,0 +1,278 @@
|
||||
---
|
||||
name: azure-mgmt-apimanagement-py
|
||||
description: |
|
||||
Azure API Management SDK for Python. Use for managing APIM services, APIs, products, subscriptions, and policies.
|
||||
Triggers: "azure-mgmt-apimanagement", "ApiManagementClient", "APIM", "API gateway", "API Management".
|
||||
package: azure-mgmt-apimanagement
|
||||
---
|
||||
|
||||
# Azure API Management SDK for Python
|
||||
|
||||
Manage Azure API Management services, APIs, products, and policies.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install azure-mgmt-apimanagement
|
||||
pip install azure-identity
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
```bash
|
||||
AZURE_SUBSCRIPTION_ID=your-subscription-id
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
```python
|
||||
from azure.identity import DefaultAzureCredential
|
||||
from azure.mgmt.apimanagement import ApiManagementClient
|
||||
import os
|
||||
|
||||
client = ApiManagementClient(
|
||||
credential=DefaultAzureCredential(),
|
||||
subscription_id=os.environ["AZURE_SUBSCRIPTION_ID"]
|
||||
)
|
||||
```
|
||||
|
||||
## Create APIM Service
|
||||
|
||||
```python
|
||||
from azure.mgmt.apimanagement.models import (
|
||||
ApiManagementServiceResource,
|
||||
ApiManagementServiceSkuProperties,
|
||||
SkuType
|
||||
)
|
||||
|
||||
service = client.api_management_service.begin_create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-apim",
|
||||
parameters=ApiManagementServiceResource(
|
||||
location="eastus",
|
||||
publisher_email="admin@example.com",
|
||||
publisher_name="My Organization",
|
||||
sku=ApiManagementServiceSkuProperties(
|
||||
name=SkuType.DEVELOPER,
|
||||
capacity=1
|
||||
)
|
||||
)
|
||||
).result()
|
||||
|
||||
print(f"Created APIM: {service.name}")
|
||||
```
|
||||
|
||||
## Import API from OpenAPI
|
||||
|
||||
```python
|
||||
from azure.mgmt.apimanagement.models import (
|
||||
ApiCreateOrUpdateParameter,
|
||||
ContentFormat,
|
||||
Protocol
|
||||
)
|
||||
|
||||
api = client.api.begin_create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-apim",
|
||||
api_id="my-api",
|
||||
parameters=ApiCreateOrUpdateParameter(
|
||||
display_name="My API",
|
||||
path="myapi",
|
||||
protocols=[Protocol.HTTPS],
|
||||
format=ContentFormat.OPENAPI_JSON,
|
||||
value='{"openapi": "3.0.0", "info": {"title": "My API", "version": "1.0"}, "paths": {"/health": {"get": {"responses": {"200": {"description": "OK"}}}}}}'
|
||||
)
|
||||
).result()
|
||||
|
||||
print(f"Imported API: {api.display_name}")
|
||||
```
|
||||
|
||||
## Import API from URL
|
||||
|
||||
```python
|
||||
api = client.api.begin_create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-apim",
|
||||
api_id="petstore",
|
||||
parameters=ApiCreateOrUpdateParameter(
|
||||
display_name="Petstore API",
|
||||
path="petstore",
|
||||
protocols=[Protocol.HTTPS],
|
||||
format=ContentFormat.OPENAPI_LINK,
|
||||
value="https://petstore.swagger.io/v2/swagger.json"
|
||||
)
|
||||
).result()
|
||||
```
|
||||
|
||||
## List APIs
|
||||
|
||||
```python
|
||||
apis = client.api.list_by_service(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-apim"
|
||||
)
|
||||
|
||||
for api in apis:
|
||||
print(f"{api.name}: {api.display_name} - {api.path}")
|
||||
```
|
||||
|
||||
## Create Product
|
||||
|
||||
```python
|
||||
from azure.mgmt.apimanagement.models import ProductContract
|
||||
|
||||
product = client.product.create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-apim",
|
||||
product_id="premium",
|
||||
parameters=ProductContract(
|
||||
display_name="Premium",
|
||||
description="Premium tier with unlimited access",
|
||||
subscription_required=True,
|
||||
approval_required=False,
|
||||
state="published"
|
||||
)
|
||||
)
|
||||
|
||||
print(f"Created product: {product.display_name}")
|
||||
```
|
||||
|
||||
## Add API to Product
|
||||
|
||||
```python
|
||||
client.product_api.create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-apim",
|
||||
product_id="premium",
|
||||
api_id="my-api"
|
||||
)
|
||||
```
|
||||
|
||||
## Create Subscription
|
||||
|
||||
```python
|
||||
from azure.mgmt.apimanagement.models import SubscriptionCreateParameters
|
||||
|
||||
subscription = client.subscription.create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-apim",
|
||||
sid="my-subscription",
|
||||
parameters=SubscriptionCreateParameters(
|
||||
display_name="My Subscription",
|
||||
scope=f"/products/premium",
|
||||
state="active"
|
||||
)
|
||||
)
|
||||
|
||||
print(f"Subscription key: {subscription.primary_key}")
|
||||
```
|
||||
|
||||
## Set API Policy
|
||||
|
||||
```python
|
||||
from azure.mgmt.apimanagement.models import PolicyContract
|
||||
|
||||
policy_xml = """
|
||||
<policies>
|
||||
<inbound>
|
||||
<rate-limit calls="100" renewal-period="60" />
|
||||
<set-header name="X-Custom-Header" exists-action="override">
|
||||
<value>CustomValue</value>
|
||||
</set-header>
|
||||
</inbound>
|
||||
<backend>
|
||||
<forward-request />
|
||||
</backend>
|
||||
<outbound />
|
||||
<on-error />
|
||||
</policies>
|
||||
"""
|
||||
|
||||
client.api_policy.create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-apim",
|
||||
api_id="my-api",
|
||||
policy_id="policy",
|
||||
parameters=PolicyContract(
|
||||
value=policy_xml,
|
||||
format="xml"
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
## Create Named Value (Secret)
|
||||
|
||||
```python
|
||||
from azure.mgmt.apimanagement.models import NamedValueCreateContract
|
||||
|
||||
named_value = client.named_value.begin_create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-apim",
|
||||
named_value_id="backend-api-key",
|
||||
parameters=NamedValueCreateContract(
|
||||
display_name="Backend API Key",
|
||||
value="secret-key-value",
|
||||
secret=True
|
||||
)
|
||||
).result()
|
||||
```
|
||||
|
||||
## Create Backend
|
||||
|
||||
```python
|
||||
from azure.mgmt.apimanagement.models import BackendContract
|
||||
|
||||
backend = client.backend.create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-apim",
|
||||
backend_id="my-backend",
|
||||
parameters=BackendContract(
|
||||
url="https://api.backend.example.com",
|
||||
protocol="http",
|
||||
description="My backend service"
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
## Create User
|
||||
|
||||
```python
|
||||
from azure.mgmt.apimanagement.models import UserCreateParameters
|
||||
|
||||
user = client.user.create_or_update(
|
||||
resource_group_name="my-resource-group",
|
||||
service_name="my-apim",
|
||||
user_id="newuser",
|
||||
parameters=UserCreateParameters(
|
||||
email="user@example.com",
|
||||
first_name="John",
|
||||
last_name="Doe"
|
||||
)
|
||||
)
|
||||
```
|
||||
|
||||
## Operation Groups
|
||||
|
||||
| Group | Purpose |
|
||||
|-------|---------|
|
||||
| `api_management_service` | APIM instance management |
|
||||
| `api` | API operations |
|
||||
| `api_operation` | API operation details |
|
||||
| `api_policy` | API-level policies |
|
||||
| `product` | Product management |
|
||||
| `product_api` | Product-API associations |
|
||||
| `subscription` | Subscription management |
|
||||
| `user` | User management |
|
||||
| `named_value` | Named values/secrets |
|
||||
| `backend` | Backend services |
|
||||
| `certificate` | Certificates |
|
||||
| `gateway` | Self-hosted gateways |
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use named values** for secrets and configuration
|
||||
2. **Apply policies** at appropriate scopes (global, product, API, operation)
|
||||
3. **Use products** to bundle APIs and manage access
|
||||
4. **Enable Application Insights** for monitoring
|
||||
5. **Use backends** to abstract backend services
|
||||
6. **Version your APIs** using APIM's versioning features
|
||||
@@ -0,0 +1,249 @@
|
||||
---
|
||||
name: azure-appconfiguration-py
|
||||
description: |
|
||||
Azure App Configuration SDK for Python. Use for centralized configuration management, feature flags, and dynamic settings.
|
||||
Triggers: "azure-appconfiguration", "AzureAppConfigurationClient", "feature flags", "configuration", "key-value settings".
|
||||
package: azure-appconfiguration
|
||||
---
|
||||
|
||||
# Azure App Configuration SDK for Python
|
||||
|
||||
Centralized configuration management with feature flags and dynamic settings.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
pip install azure-appconfiguration
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
|
||||
```bash
|
||||
AZURE_APPCONFIGURATION_CONNECTION_STRING=Endpoint=https://<name>.azconfig.io;Id=...;Secret=...
|
||||
# Or for Entra ID:
|
||||
AZURE_APPCONFIGURATION_ENDPOINT=https://<name>.azconfig.io
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
### Connection String
|
||||
|
||||
```python
|
||||
from azure.appconfiguration import AzureAppConfigurationClient
|
||||
|
||||
client = AzureAppConfigurationClient.from_connection_string(
|
||||
os.environ["AZURE_APPCONFIGURATION_CONNECTION_STRING"]
|
||||
)
|
||||
```
|
||||
|
||||
### Entra ID
|
||||
|
||||
```python
|
||||
from azure.appconfiguration import AzureAppConfigurationClient
|
||||
from azure.identity import DefaultAzureCredential
|
||||
|
||||
client = AzureAppConfigurationClient(
|
||||
base_url=os.environ["AZURE_APPCONFIGURATION_ENDPOINT"],
|
||||
credential=DefaultAzureCredential()
|
||||
)
|
||||
```
|
||||
|
||||
## Configuration Settings
|
||||
|
||||
### Get Setting
|
||||
|
||||
```python
|
||||
setting = client.get_configuration_setting(key="app:settings:message")
|
||||
print(f"{setting.key} = {setting.value}")
|
||||
```
|
||||
|
||||
### Get with Label
|
||||
|
||||
```python
|
||||
# Labels allow environment-specific values
|
||||
setting = client.get_configuration_setting(
|
||||
key="app:settings:message",
|
||||
label="production"
|
||||
)
|
||||
```
|
||||
|
||||
### Set Setting
|
||||
|
||||
```python
|
||||
from azure.appconfiguration import ConfigurationSetting
|
||||
|
||||
setting = ConfigurationSetting(
|
||||
key="app:settings:message",
|
||||
value="Hello, World!",
|
||||
label="development",
|
||||
content_type="text/plain",
|
||||
tags={"environment": "dev"}
|
||||
)
|
||||
|
||||
client.set_configuration_setting(setting)
|
||||
```
|
||||
|
||||
### Delete Setting
|
||||
|
||||
```python
|
||||
client.delete_configuration_setting(
|
||||
key="app:settings:message",
|
||||
label="development"
|
||||
)
|
||||
```
|
||||
|
||||
## List Settings
|
||||
|
||||
### All Settings
|
||||
|
||||
```python
|
||||
settings = client.list_configuration_settings()
|
||||
for setting in settings:
|
||||
print(f"{setting.key} [{setting.label}] = {setting.value}")
|
||||
```
|
||||
|
||||
### Filter by Key Prefix
|
||||
|
||||
```python
|
||||
settings = client.list_configuration_settings(
|
||||
key_filter="app:settings:*"
|
||||
)
|
||||
```
|
||||
|
||||
### Filter by Label
|
||||
|
||||
```python
|
||||
settings = client.list_configuration_settings(
|
||||
label_filter="production"
|
||||
)
|
||||
```
|
||||
|
||||
## Feature Flags
|
||||
|
||||
### Set Feature Flag
|
||||
|
||||
```python
|
||||
from azure.appconfiguration import ConfigurationSetting
|
||||
import json
|
||||
|
||||
feature_flag = ConfigurationSetting(
|
||||
key=".appconfig.featureflag/beta-feature",
|
||||
value=json.dumps({
|
||||
"id": "beta-feature",
|
||||
"enabled": True,
|
||||
"conditions": {
|
||||
"client_filters": []
|
||||
}
|
||||
}),
|
||||
content_type="application/vnd.microsoft.appconfig.ff+json;charset=utf-8"
|
||||
)
|
||||
|
||||
client.set_configuration_setting(feature_flag)
|
||||
```
|
||||
|
||||
### Get Feature Flag
|
||||
|
||||
```python
|
||||
setting = client.get_configuration_setting(
|
||||
key=".appconfig.featureflag/beta-feature"
|
||||
)
|
||||
flag_data = json.loads(setting.value)
|
||||
print(f"Feature enabled: {flag_data['enabled']}")
|
||||
```
|
||||
|
||||
### List Feature Flags
|
||||
|
||||
```python
|
||||
flags = client.list_configuration_settings(
|
||||
key_filter=".appconfig.featureflag/*"
|
||||
)
|
||||
for flag in flags:
|
||||
data = json.loads(flag.value)
|
||||
print(f"{data['id']}: {'enabled' if data['enabled'] else 'disabled'}")
|
||||
```
|
||||
|
||||
## Read-Only Settings
|
||||
|
||||
```python
|
||||
# Make setting read-only
|
||||
client.set_read_only(
|
||||
configuration_setting=setting,
|
||||
read_only=True
|
||||
)
|
||||
|
||||
# Remove read-only
|
||||
client.set_read_only(
|
||||
configuration_setting=setting,
|
||||
read_only=False
|
||||
)
|
||||
```
|
||||
|
||||
## Snapshots
|
||||
|
||||
### Create Snapshot
|
||||
|
||||
```python
|
||||
from azure.appconfiguration import ConfigurationSnapshot, ConfigurationSettingFilter
|
||||
|
||||
snapshot = ConfigurationSnapshot(
|
||||
name="v1-snapshot",
|
||||
filters=[
|
||||
ConfigurationSettingFilter(key="app:*", label="production")
|
||||
]
|
||||
)
|
||||
|
||||
created = client.begin_create_snapshot(
|
||||
name="v1-snapshot",
|
||||
snapshot=snapshot
|
||||
).result()
|
||||
```
|
||||
|
||||
### List Snapshot Settings
|
||||
|
||||
```python
|
||||
settings = client.list_configuration_settings(
|
||||
snapshot_name="v1-snapshot"
|
||||
)
|
||||
```
|
||||
|
||||
## Async Client
|
||||
|
||||
```python
|
||||
from azure.appconfiguration.aio import AzureAppConfigurationClient
|
||||
from azure.identity.aio import DefaultAzureCredential
|
||||
|
||||
async def main():
|
||||
credential = DefaultAzureCredential()
|
||||
client = AzureAppConfigurationClient(
|
||||
base_url=endpoint,
|
||||
credential=credential
|
||||
)
|
||||
|
||||
setting = await client.get_configuration_setting(key="app:message")
|
||||
print(setting.value)
|
||||
|
||||
await client.close()
|
||||
await credential.close()
|
||||
```
|
||||
|
||||
## Client Operations
|
||||
|
||||
| Operation | Description |
|
||||
|-----------|-------------|
|
||||
| `get_configuration_setting` | Get single setting |
|
||||
| `set_configuration_setting` | Create or update setting |
|
||||
| `delete_configuration_setting` | Delete setting |
|
||||
| `list_configuration_settings` | List with filters |
|
||||
| `set_read_only` | Lock/unlock setting |
|
||||
| `begin_create_snapshot` | Create point-in-time snapshot |
|
||||
| `list_snapshots` | List all snapshots |
|
||||
|
||||
## Best Practices
|
||||
|
||||
1. **Use labels** for environment separation (dev, staging, prod)
|
||||
2. **Use key prefixes** for logical grouping (app:database:*, app:cache:*)
|
||||
3. **Make production settings read-only** to prevent accidental changes
|
||||
4. **Create snapshots** before deployments for rollback capability
|
||||
5. **Use Entra ID** instead of connection strings in production
|
||||
6. **Refresh settings periodically** in long-running applications
|
||||
7. **Use feature flags** for gradual rollouts and A/B testing
|
||||
Reference in New Issue
Block a user