kid-sid/claude-spellbook/azure

Claude Code and agent skill by kid-sid/claude-spellbook

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Use when writing Python code that integrates with Azure Blob Storage, AI Search, Document Intelligence, or Key Vault — or when configuring Managed Identity auth, designing a hybrid search index, or troubleshooting Azure SDK retry behavior.

Install

npx vskill@latest install kid-sid/claude-spellbook/azure

SKILL.md

Azure SDK

Production patterns for Azure services in Python using the official Azure SDKs.

When to Activate

  • Writing code that imports azure-storage-blob, azure-search-documents, azure-ai-formrecognizer, or azure-identity
  • Configuring authentication for Azure services (Managed Identity, service principals, connection strings)
  • Designing or querying an Azure AI Search index (vector, text, hybrid)
  • Extracting content from documents using Azure Document Intelligence
  • Managing secrets with Azure Key Vault
  • Deploying a pipeline as an Azure Function
  • Troubleshooting Azure SDK errors or retry behavior

Authentication

DefaultAzureCredential (always prefer this)
python
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient
credential = DefaultAzureCredential()
client = BlobServiceClient(account_url="https://<account>.blob.core.windows.net", credential=credential)

DefaultAzureCredential tries, in order: environment variables → Managed Identity → Azure CLI → VS Code → Interactive browser. The same code works locally (via CLI auth) and in production (via Managed Identity) without changes.

python
# BAD: connection string hardcoded
client = BlobServiceClient.from_connection_string("DefaultEndpointsProtocol=https;AccountName=...")
# BAD: key hardcoded
client = BlobServiceClient(account_url=url, credential="storage-account-key-here")
# GOOD: keyless auth
credential = DefaultAzureCredential()
client = BlobServiceClient(account_url=url, credential=credential)
Auth decision matrix
EnvironmentCredential typeHow to enable
Local devAzure CLIaz login
CI/CDService principal (env vars)Set AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, AZURE_TENANT_ID
Azure VM / AKSSystem-assigned Managed IdentityEnable on the resource in portal/Bicep
Azure FunctionsUser-assigned Managed IdentitySet AZURE_CLIENT_ID env var
TestingClientSecretCredentialExplicit — never use in production code

Configuration (pydantic-settings)

python
from pydantic_settings import BaseSettings
class AzureSettings(BaseSettings):
azure_storage_account_url: str
azure_search_endpoint: str
azure_search_index_name: str
azure_document_intelligence_endpoint: str
azure_key_vault_url: str | None = None
class Config:
env_file = ".env"
env_file_encoding = "utf-8"
settings = AzureSettings()

Never store credentials in settings — let DefaultAzureCredential handle them.

Azure Blob Storage

Upload
python
from azure.storage.blob import BlobServiceClient, ContentSettings
def upload_file(account_url: str, container: str, blob_name: str, data: bytes, content_type: str) -> str:
credential = DefaultAzureCredential()
client = BlobServiceClient(account_url=account_url, credential=credential)
blob = client.get_blob_client(container=container, blob=blob_name)
blob.upload_blob(
data,
overwrite=True,
content_settings=ContentSettings(content_type=content_type),
)
return blob.url
Download and list
python
def download_blob(account_url: str, container: str, blob_name: str) -> bytes:
client = BlobServiceClient(account_url=account_url, credential=DefaultAzureCredential())
blob = client.get_blob_client(container=container, blob=blob_name)
return blob.download_blob().readall()
def list_blobs(account_url: str, container: str, prefix: str = "") -> list[str]:
client = BlobServiceClient(account_url=account_url, credential=DefaultAzureCredential())
container_client = client.get_container_client(container)
return [b.name for b in container_client.list_blobs(name_starts_with=prefix)]
SAS token (time-limited read access)
python
from datetime import datetime, timedelta, timezone
from azure.storage.blob import generate_blob_sas, BlobSasPermissions
def get_sas_url(account_name: str, account_key: str, container: str, blob: str, expiry_hours: int = 1) -> str:
sas = generate_blob_sas(
account_name=account_name,
container_name=container,
blob_name=blob,
account_key=account_key,
permission=BlobSasPermissions(read=True),
expiry=datetime.now(timezone.utc) + timedelta(hours=expiry_hours),
)
return f"https://{account_name}.blob.core.windows.net/{container}/{blob}?{sas}"

Azure AI Search

Index schema (with vector field)
python
from azure.search.documents.indexes import SearchIndexClient
from azure.search.documents.indexes.models import (
SearchIndex, SimpleField, SearchableField, SearchFieldDataType,
VectorSearch, HnswAlgorithmConfiguration, VectorSearchProfile,
SearchField, SemanticConfiguration, SemanticSearch, SemanticPrioritizedFields,
SemanticField,
)
def create_index(endpoint: str, index_name: str) -> None:
client = SearchIndexClient(endpoint=endpoint, credential=DefaultAzureCredential())
fields = [
SimpleField(name="id", type=SearchFieldDataType.String, key=True),
SearchableField(name="content", type=SearchFieldDataType.String),
SearchableField(name="title", type=SearchFieldDataType.String),
SimpleField(name="source", type=SearchFieldDataType.String, filterable=True),
SimpleField(name="chunk_index", type=SearchFieldDataType.Int32, filterable=True),
SearchField(
name="content_vector",
type=SearchFieldDataType.Collection(SearchFieldDataType.Single),
searchable=True,
vector_search_dimensions=1536,
vector_search_profile_name="hnsw-profile",
),
]
vector_search = VectorSearch(
algorithms=[HnswAlgorithmConfiguration(name="hnsw")],
profiles=[VectorSearchProfile(name="hnsw-profile", algorithm_configuration_name="hnsw")],
)
semantic_search = SemanticSearch(
configurations=[
SemanticConfiguration(
name="default",
prioritized_fields=SemanticPrioritizedFields(
content_fields=[SemanticField(field_name="content")],
title_field=SemanticField(field_name="title"),
),
)
]
)
index = SearchIndex(
name=index_name,
fields=fields,
vector_search=vector_search,
semantic_search=semantic_search,
)
client.create_or_update_index(index)
Upload documents
python
from azure.search.documents import SearchClient
def upload_documents(endpoint: str, index_name: str, docs: list[dict]) -> None:
client = SearchClient(
endpoint=endpoint,
index_name=index_name,
credential=DefaultAzureCredential(),
)
# Batch in chunks of 1000 (SDK limit)
for i in range(0, len(docs), 1000):
result = client.upload_documents(documents=docs[i:i + 1000])
failed = [r for r in result if not r.succeeded]
if failed:
raise RuntimeError(f"{len(failed)} documents failed to index: {failed[0].key}")
Search: text / vector / hybrid
python
from azure.search.documents.models import VectorizedQuery
def search(
endpoint: str,
index_name: str,
query: str,
query_vector: list[float],
top: int = 5,
mode: str = "hybrid", # "text" | "vector" | "hybrid"
filter_expr: str | None = None,
) -> list[dict]:
client = SearchClient(endpoint=endpoint, index_name=index_name, credential=DefaultAzureCredential())
vector_query = VectorizedQuery(
vector=query_vector,
k_nearest_neighbors=top,
fields="content_vector",
) if mode in ("vector", "hybrid") else None
results = client.search(
search_text=query if mode in ("text", "hybrid") else None,
vector_queries=[vector_query] if vector_query else None,
filter=filter_expr,
top=top,
query_type="semantic" if mode == "hybrid" else "simple",
semantic_configuration_name="default" if mode == "hybrid" else None,
)
return [dict(r) for r in results]
Search mode comparison
ModeWhen to useRelevanceCost
TextKeyword lookup, exact matchesLowLowest
VectorSemantic similarity, paraphraseHighMedium
HybridProduction RAG (default choice)HighestMedium
Semantic rerankingHigh-precision Q&A on top of hybridHighestHigher

Azure Document Intelligence

python
from azure.ai-formrecognizer import DocumentAnalysisClient
def analyze_document(endpoint: str, file_bytes: bytes, model_id: str = "prebuilt-read") -> dict:
client = DocumentAnalysisClient(endpoint=endpoint, credential=DefaultAzureCredential())
poller = client.begin_analyze_document(model_id, document=file_bytes)
result = poller.result()
return {
"content": result.content,
"pages": len(result.pages),
"tables": [
{
"row_count": t.row_count,
"column_count": t.column_count,
"cells": [{"row": c.row_index, "col": c.column_index, "text": c.content} for c in t.cells],
}
for t in (result.tables or [])
],
}
Model selection
Model IDBest for
prebuilt-readText extraction from any document
prebuilt-layoutTables, checkboxes, structure-aware extraction
prebuilt-documentKey-value pairs + tables
prebuilt-invoiceInvoices
prebuilt-receiptReceipts
Custom modelDomain-specific forms with consistent layout

Key Vault

python
from azure.keyvault.secrets import SecretClient
def get_secret(vault_url: str, secret_name: str) -> str:
client = SecretClient(vault_url=vault_url, credential=DefaultAzureCredential())
return client.get_secret(secret_name).value
# Cache the client — don't recreate per call
_kv_client: SecretClient | None = None
def kv_client(vault_url: str) -> SecretClient:
global _kv_client
if _kv_client is None:
_kv_client = SecretClient(vault_url=vault_url, credential=DefaultAzureCredential())
return _kv_client

Retry with tenacity

python
from tenacity import retry, stop_after_attempt, wait_exponential, retry_if_exception_type
from azure.core.exceptions import HttpResponseError, ServiceRequestError
def is_retryable(exc: Exception) -> bool:
if isinstance(exc, HttpResponseError):
return exc.status_code in (429, 500, 502, 503, 504)
return isinstance(exc, ServiceRequestError)
@retry(
retry=retry_if_exception_type((HttpResponseError, ServiceRequestError)),
wait=wait_exponential(multiplier=1, min=2, max=60),
stop=stop_after_attempt(5),
reraise=True,
)
def upload_with_retry(client: SearchClient, docs: list[dict]) -> None:
client.upload_documents(documents=docs)

Error handling

python
from azure.core.exceptions import (
HttpResponseError,
ResourceNotFoundError,
ResourceExistsError,
ClientAuthenticationError,
ServiceRequestError,
)
try:
result = client.get_document(key="doc-123")
except ResourceNotFoundError:
# Document does not exist — handle gracefully
return None
except ClientAuthenticationError:
# Credential expired or RBAC role missing — fail fast
raise
except HttpResponseError as e:
if e.status_code == 429:
# Throttled — tenacity will handle retry
raise
logger.error("azure_error", status=e.status_code, message=e.message)
raise

Cost controls

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 95 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
186
Repository forks
15
7-day trend score
26

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/kid-sid/claude-spellbook/azure/badge)](https://verified-skill.com/skills/kid-sid/claude-spellbook/azure)

Something wrong with this skill or its page? Tell us.