Robertjam954/multimodal_rag_application / .claude/skills/azure-prepare
azure-prepare
FlaggedPrepare Azure apps for deployment (infra Bicep/Terraform, azure.yaml, Dockerfiles). Use for create/modernize or create+deploy; not cross-cloud migration (use azure-cloud-migrate). DO NOT USE FOR: copilot-sdk apps (use azure-hosted-copilot-sdk), or Python code-only App Service deploys (use python-appservice-deploy). WHEN: "create app", "build web app", "create API", "modernize application", "host on Azure", "deploy to Azure", "deploy to Azure using Terraform", "deploy to Azure App Service", "deploy to Azure App Service using Terraform", "deploy to Azure Container Apps", "generate Terraform", "generate Bicep", "function app", "timer trigger", "service bus trigger", "event-driven function", "managed identity".
references/services/durable-task-scheduler/python.md
View on GitHub# Durable Task Scheduler — Python
## Learn More
- [Durable Task Scheduler documentation](https://learn.microsoft.com/azure/durable-task-scheduler/)
- [Durable Functions Python guide](https://learn.microsoft.com/azure/azure-functions/durable/durable-functions-overview?tabs=python)
## Durable Functions Setup
### Required Packages
```txt
# requirements.txt
azure-functions
azure-functions-durable
azure-identity
```
> **💡 Finding latest versions**: Run `pip index versions azure-functions-durable` or check [pypi.org/project/azure-functions-durable](https://pypi.org/project/azure-functions-durable/) for the latest stable release.
### host.json
```json
{
"version": "2.0",
"extensions": {
"durableTask": {
"hubName": "default",
"storageProvider": {
"type": "durabletask-scheduler",
"connectionStringName": "DURABLE_TASK_SCHEDULER_CONNECTION_STRING"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
```
> **💡 NOTE**: Python uses extension bundles, so the storage provider type is `durabletask-scheduler`. .NET isolated uses the NuGet package directly and requires `azureManaged` instead — see [dotnet.md](dotnet.md).
### local.settings.json
```json
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"DURABLE_TASK_SCHEDULER_CONNECTION_STRING": "Endpoint=http://localhost:8080;TaskHub=default;Authentication=None"
}
}
```
## Minimal Example
```python
import azure.functions as func
import azure.durable_functions as df
my_app = df.DFApp(http_auth_level=func.AuthLevel.FUNCTION)
# HTTP Starter
@my_app.route(route="orchestrators/{function_name}", methods=["POST"])
@my_app.durable_client_input(client_name="client")
async def http_start(req: func.HttpRequest, client):
function_name = req.route_params.get('function_name')
instance_id = await client.start_new(function_name)
return client.create_check_status_response(req, instance_id)
# Orchestrator
@my_app.orchestration_trigger(context_name="context")
def my_orchestration(context: df.DurableOrchestrationContext):
result1 = yield context.call_activity("say_hello", "Tokyo")
result2 = yield context.call_activity("say_hello", "Seattle")
return f"{result1}, {result2}"
# Activity
@my_app.activity_trigger(input_name="name")
def say_hello(name: str) -> str:
return f"Hello {name}!"
```
## Workflow Patterns
### Fan-Out/Fan-In
```python
@my_app.orchestration_trigger(context_name="context")
def fan_out_fan_in(context: df.DurableOrchestrationContext):
cities = ["Tokyo", "Seattle", "London", "Paris", "Berlin"]
# Fan-out: schedule all in parallel
parallel_tasks = []
for city in cities:
task = context.call_activity("say_hello", city)
parallel_tasks.append(task)
# Fan-in: wait for all
results = yield context.task_all(parallel_tasks)
return results
```
### Human Interaction
```python
import datetime
@my_app.orchestration_trigger(context_name="context")
def approval_workflow(context: df.DurableOrchestrationContext):
yield context.call_activity("send_approval_request", context.get_input())
# Wait for approval event with timeout
timeout = context.current_utc_datetime + datetime.timedelta(days=3)
approval_task = context.wait_for_external_event("ApprovalEvent")
timeout_task = context.create_timer(timeout)
winner = yield context.task_any([approval_task, timeout_task])
if winner == approval_task:
approved = approval_task.result
return "Approved" if approved else "Rejected"
return "Timed out"
```
## Orchestration Determinism
| ❌ NEVER | ✅ ALWAYS USE |
|----------|--------------|
| `datetime.now()` | `context.current_utc_datetime` |
| `uuid.uuid4()` | `context.new_uuid()` |
| `random.random()` | Pass random values from activities |
| `time.sleep()` | `context.create_timer()` |
| Direct I/O, HTTP, database | `context.call_activity()` |
### Replay-Safe Logging
```python
import logging
@my_app.orchestration_trigger(context_name="context")
def my_orchestration(context: df.DurableOrchestrationContext):
# Check if replaying to avoid duplicate logs
if not context.is_replaying:
logging.info("Started") # Only logs once, not on replay
result = yield context.call_activity("my_activity", "input")
return result
```
## Error Handling & Retry
```python
retry_options = df.RetryOptions(
first_retry_interval_in_milliseconds=5000,
max_number_of_attempts=3,
backoff_coefficient=2.0,
max_retry_interval_in_milliseconds=60000
)
@my_app.orchestration_trigger(context_name="context")
def workflow_with_retry(context: df.DurableOrchestrationContext):
try:
result = yield context.call_activity_with_retry(
"unreliable_service",
retry_options,
context.get_input()
)
return result
except Exception as ex:
context.set_custom_status({"error": str(ex)})
yield context.call_activity("compensation_activity", context.get_input())
return "Compensated"
```
## Durable Task SDK (Non-Functions)
For applications running outside Azure Functions (containers, VMs, Azure Container Apps, Azure Kubernetes Service):
```python
import asyncio
from durabletask.azuremanaged.worker import DurableTaskSchedulerWorker
# Activity function
def say_hello(ctx, name: str) -> str:
return f"Hello {name}!"
# Orchestrator function
def my_orchestration(ctx, name: str) -> str:
result = yield ctx.call_activity('say_hello', input=name)
return result
async def main():
with DurableTaskSchedulerWorker(
host_address="http://localhost:8080",
secure_channel=False,
taskhub="default"
) as worker:
worker.add_activity(say_hello)
worker.add_orchestrator(my_orchestration)
worker.start()
# Client
from durabletask.azuremanaged.client import DurableTaskSchedulerClient
client = DurableTaskSchedulerClient(
host_address="http://localhost:8080",
taskhub="default",
token_credential=None,
secure_channel=False
)
instance_id = client.schedule_new_orchestration("my_orchestration", input="World")
result = client.wait_for_orchestration_completion(instance_id, timeout=30)
print(f"Output: {result.serialized_output}")
if __name__ == "__main__":
asyncio.run(main())
```
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 321k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |