Skip to main content

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

azwrap-0.1.1.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

azwrap-0.1.1-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file azwrap-0.1.1.tar.gz.

File metadata

  • Download URL: azwrap-0.1.1.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for azwrap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6fc24f26ce8695bde32e083e58851017aa0d5b3f8eaeecfc70bba65684faf8ad
MD5 e00cfc3f665194e4f385ee0b8ba64028
BLAKE2b-256 4f25571ea637af5db763365b6df03917f6ab1ee2fbe4f282096922dc434154fd

See more details on using hashes here.

File details

Details for the file azwrap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: azwrap-0.1.1-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

Hashes for azwrap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9bc005187e7f095f7d02312b7a1c32207e3c24992c77a1fe186270b23c996510
MD5 9dc9fd8fe6061adfdedcf60d85d64c72
BLAKE2b-256 eeaf928ad510507dfc3b93bb9142fbdfff4f499927718ed0d6a5c40b5fac3a51

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page