Azure deployment wrapper
Project description
AzWrap
A Python package that provides a streamlined wrapper for Azure resource management, making it easier to work with Azure services including:
- Azure Storage
- Azure AI Search
- Azure OpenAI
Installation
pip install azwrap
Configuration
AzWrap requires Azure credentials to be set either as environment variables or in a .env file:
AZURE_TENANT_ID=your-tenant-id
AZURE_CLIENT_ID=your-client-id
AZURE_CLIENT_SECRET=your-client-secret
AZURE_SUBSCRIPTION_ID=your-subscription-id
CLI Usage
Once installed, you can use the CLI to manage Azure resources:
# List all available subscriptions
azwrap list-subscriptions
# List resource groups in a subscription
azwrap list-resource-groups -s your-subscription-id
# List Azure AI Search services
azwrap list-search -s your-subscription-id
# List Azure OpenAI services
azwrap list-ai -s your-subscription-id
Python API Usage
Identity Management
from azwrap import Identity
# Create an identity with your Azure credentials
identity = Identity(tenant_id, client_id, client_secret)
# Get a list of subscriptions
subscriptions = identity.get_subscriptions()
# Get a specific subscription
subscription = identity.get_subscription(subscription_id)
Resource Management
from azwrap import Subscription, ResourceGroup
# Work with resource groups
resource_group = subscription.get_resource_group(group_name)
# Create a new resource group
new_group = subscription.create_resource_group(group_name, location)
Storage Management
from azwrap import StorageAccount, Container
# Get a storage account
storage_account = resource_group.get_storage_account(account_name)
# Create a new storage account
new_account = resource_group.create_storage_account(account_name, location)
# Work with blob containers
container = storage_account.get_container(container_name)
blobs = container.get_blobs()
Azure AI Search
from azwrap import SearchService, SearchIndex, get_std_vector_search
from azure.search.documents.indexes.models import (
SearchField, SearchFieldDataType, SimpleField, SearchableField
)
# Get a search service
search_service = subscription.get_search_service(service_name)
# Create a new search service
new_service = resource_group.create_search_service(name, location)
# Define fields for an index
fields = [
SimpleField(name="id", type=SearchFieldDataType.String, key=True),
SearchableField(name="content", type=SearchFieldDataType.String, analyzer_name="en.microsoft")
]
# Create a search index
index = search_service.create_or_update_index("my-index", fields)
# Add vector search capability
vector_search = get_std_vector_search()
Azure OpenAI
from azwrap import AIService, OpenAIClient
# Get an OpenAI service
ai_service = resource_group.get_ai_service(service_name)
# Get OpenAI client with Azure credentials
openai_client = ai_service.get_OpenAIClient(api_version="2023-05-15")
# Generate embeddings
embeddings = openai_client.generate_embeddings("Your text here", model="deployment-name")
# Generate chat completions
response = openai_client.generate_chat_completion(
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Tell me about Azure."}
],
model="deployment-name",
temperature=0.7,
max_tokens=800
)
Development
To set up the development environment:
# Clone the repository
git clone https://github.com/yourusername/azwrap.git
cd azwrap
# Create a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies for development
uv sync
# Build the package
python -m build
# Install in development mode
pip install -e .
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file azwrap-0.1.0.tar.gz.
File metadata
- Download URL: azwrap-0.1.0.tar.gz
- Upload date:
- Size: 14.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9592dcfc4b89b94a84b3b955da861ae80beee985a7b52a314b5be7e10894d012
|
|
| MD5 |
b0b4cf4980e41229435f6a1054d1e3e2
|
|
| BLAKE2b-256 |
6adb0efd20990b89f92e27de490489a0193a2fefa78aa7b079b46c55d58e5ab2
|
File details
Details for the file azwrap-0.1.0-py3-none-any.whl.
File metadata
- Download URL: azwrap-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
819edbb59a8e78f1b1da9d8b785ce6df17cc5a589f96a4dfd51303dccbf5e38f
|
|
| MD5 |
91c784122c901f36e5c45b50ea2d8e98
|
|
| BLAKE2b-256 |
97d7f63b6a9e12f0513f61796ebeb1dd63a3d731839083ad150475d7a075d514
|