diff --git a/docs/examples/connectors/azure/azure.vjs.example b/docs/examples/connectors/azure/azure.vjs.example new file mode 100644 index 0000000..ed99fd3 --- /dev/null +++ b/docs/examples/connectors/azure/azure.vjs.example @@ -0,0 +1,59 @@ +# connector: azure — Comprehensive Microsoft Azure API integration +# +# Platform connector for Microsoft Azure. Supports multiple operations: +# - Blob Storage (upload, download, list, delete blobs) +# - Service Bus (send messages, receive messages, queues/topics) +# - Azure Functions (invoke functions, list functions) +# - Event Grid (publish events, create topics) +# - Cosmos DB (CRUD operations on documents) +# +# Uses http-out driver for API calls. Azure requires OAuth2 Azure AD authentication. +# Individual operations use flows that consume from subjects and make direct API calls. +# +# Subjects: +# IN: vx.azure.blob.upload (upload blobs to Blob Storage) +# IN: vx.azure.servicebus.send (send messages to Service Bus) +# IN: vx.azure.functions.invoke (invoke Azure Functions) +# +# Secrets: +# azure/storage_account - Azure Storage account name +# azure/storage_key - Azure Storage account access key +# azure/tenant_id - Azure AD tenant ID +# azure/client_id - Azure AD application (client) ID +# azure/client_secret - Azure AD client secret +# +# Rate limits: Varies by service (Blob Storage: 20000 req/s, Service Bus: varies by tier) +# Pagination: Service-specific (continuation tokens) +# +# Authentication: Shared Key for Storage, OAuth2 Bearer token for other services +# API Version: Service-specific (2021-08-06 for Blob Storage, etc.) +# +# Note: Azure authentication varies by service. Storage uses Shared Key, +# other services use OAuth2 tokens from Azure AD. This connector demonstrates +# the structure; actual implementation would need service-specific auth helpers +# or use Azure SDK wrapped in exec-rpc. + +driver "http-out" + +# Base configuration for Blob Storage operations +SUBJECT = "vx.azure.blob.upload" +BASE_URL = "https://" + secret("azure/storage_account") + ".blob.core.windows.net" +METHOD = "PUT" + +# Shared Key authentication for Blob Storage +# In production, this would use an exec-rpc wrapper around Azure SDK +# or a signing service that generates proper Authorization headers +HEADERS = { + "x-ms-date": "${timestamp}", + "x-ms-version": "2021-08-06", + Authorization: "SharedKey " + secret("azure/storage_account") + ":${signature}", + "x-ms-blob-type": "BlockBlob", + "Content-Type": "application/octet-stream" +} + +# Note: For production use, consider wrapping Azure SDK in exec-rpc connector +# to handle OAuth2 token generation and service-specific APIs properly. +# Azure AD authentication flow (for non-storage services): +# 1. POST to https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token +# 2. Use client credentials grant (client_id, client_secret, scope) +# 3. Use access token in Authorization: Bearer header diff --git a/docs/examples/connectors/azure/fixture.json b/docs/examples/connectors/azure/fixture.json new file mode 100644 index 0000000..cf36b5e --- /dev/null +++ b/docs/examples/connectors/azure/fixture.json @@ -0,0 +1,16 @@ +{ + "Last-Modified": "Mon, 23 Nov 2026 12:00:00 GMT", + "ETag": "\"0x8DCEB1234567890\"", + "Content-Length": "2048", + "Content-Type": "application/octet-stream", + "x-ms-request-id": "12345678-1234-1234-1234-123456789012", + "x-ms-version": "2021-08-06", + "x-ms-blob-type": "BlockBlob", + "x-ms-lease-status": "unlocked", + "x-ms-lease-state": "available", + "x-ms-server-encrypted": "true", + "Date": "Mon, 23 Nov 2026 12:00:00 GMT", + "Container": "uploads", + "Blob": "document.pdf", + "URL": "https://mystorageaccount.blob.core.windows.net/uploads/document.pdf" +} diff --git a/docs/examples/connectors/azure/mock.mjs b/docs/examples/connectors/azure/mock.mjs new file mode 100644 index 0000000..4e48639 --- /dev/null +++ b/docs/examples/connectors/azure/mock.mjs @@ -0,0 +1,168 @@ +#!/usr/bin/env node +// Mock Azure Blob Storage API server for admission testing +// Simulates /{container}/{blob} endpoint + +import http from 'http'; + +const containers = { + 'uploads': {} +}; + +const server = http.createServer((req, res) => { + // CORS headers + res.setHeader('Access-Control-Allow-Origin', '*'); + res.setHeader('Access-Control-Allow-Methods', 'GET, PUT, DELETE, HEAD, OPTIONS'); + res.setHeader('Access-Control-Allow-Headers', 'Authorization, x-ms-date, x-ms-version, x-ms-blob-type, Content-Type'); + + if (req.method === 'OPTIONS') { + res.writeHead(200); + res.end(); + return; + } + + const url = new URL(req.url, `http://${req.headers.host}`); + const pathParts = url.pathname.split('/').filter(p => p); + + // PUT /{container}/{blob} - upload blob + if (req.method === 'PUT' && pathParts.length >= 2) { + const container = pathParts[0]; + const blob = pathParts.slice(1).join('/'); + + if (!containers[container]) { + res.writeHead(404, { 'Content-Type': 'application/xml' }); + res.end(` + + ContainerNotFound + The specified container does not exist. +`); + return; + } + + let body = ''; + req.on('data', chunk => body += chunk); + req.on('end', () => { + containers[container][blob] = body; + + const now = new Date().toUTCString(); + res.writeHead(201, { + 'Content-Length': '0', + 'Last-Modified': now, + 'ETag': '"0x8DCEB' + Date.now().toString(16).toUpperCase() + '"', + 'x-ms-request-id': '12345678-1234-1234-1234-123456789012', + 'x-ms-version': '2021-08-06', + 'x-ms-blob-type': 'BlockBlob', + 'x-ms-server-encrypted': 'true', + 'Date': now + }); + res.end(); + }); + return; + } + + // GET /{container}/{blob} - get blob + if (req.method === 'GET' && pathParts.length >= 2) { + const container = pathParts[0]; + const blob = pathParts.slice(1).join('/'); + + if (!containers[container]) { + res.writeHead(404, { 'Content-Type': 'application/xml' }); + res.end(` + + ContainerNotFound + The specified container does not exist. +`); + return; + } + + if (!containers[container][blob]) { + res.writeHead(404, { 'Content-Type': 'application/xml' }); + res.end(` + + BlobNotFound + The specified blob does not exist. +`); + return; + } + + const now = new Date().toUTCString(); + res.writeHead(200, { + 'Content-Type': 'application/octet-stream', + 'Content-Length': String(containers[container][blob].length), + 'Last-Modified': now, + 'ETag': '"0x8DCEB' + Date.now().toString(16).toUpperCase() + '"', + 'x-ms-request-id': '12345678-1234-1234-1234-123456789012', + 'x-ms-version': '2021-08-06', + 'x-ms-blob-type': 'BlockBlob', + 'Date': now + }); + res.end(containers[container][blob]); + return; + } + + // DELETE /{container}/{blob} - delete blob + if (req.method === 'DELETE' && pathParts.length >= 2) { + const container = pathParts[0]; + const blob = pathParts.slice(1).join('/'); + + if (containers[container] && containers[container][blob]) { + delete containers[container][blob]; + } + + const now = new Date().toUTCString(); + res.writeHead(202, { + 'x-ms-request-id': '12345678-1234-1234-1234-123456789012', + 'x-ms-version': '2021-08-06', + 'Date': now + }); + res.end(); + return; + } + + // GET /{container}?restype=container&comp=list - list blobs + if (req.method === 'GET' && pathParts.length === 1 && url.searchParams.get('restype') === 'container' && url.searchParams.get('comp') === 'list') { + const container = pathParts[0]; + + if (!containers[container]) { + res.writeHead(404, { 'Content-Type': 'application/xml' }); + res.end(` + + ContainerNotFound + The specified container does not exist. +`); + return; + } + + const blobs = Object.keys(containers[container]).map(name => ` + + ${name} + + ${new Date().toUTCString()} + "0x8DCEB${Date.now().toString(16).toUpperCase()}" + ${containers[container][name].length} + application/octet-stream + BlockBlob + + `).join(''); + + res.writeHead(200, { 'Content-Type': 'application/xml' }); + res.end(` + + ${blobs} + +`); + return; + } + + // 404 for unknown endpoints + res.writeHead(404, { 'Content-Type': 'application/xml' }); + res.end(` + + ResourceNotFound + The specified resource does not exist. +`); +}); + +const PORT = process.env.PORT || 8086; +server.listen(PORT, () => { + console.log(`Mock Azure Blob Storage API listening on port ${PORT}`); +}); diff --git a/docs/examples/connectors/azure/overrides.json b/docs/examples/connectors/azure/overrides.json new file mode 100644 index 0000000..e5a4072 --- /dev/null +++ b/docs/examples/connectors/azure/overrides.json @@ -0,0 +1,4 @@ +{ + "BASE_URL": "http://localhost:8086", + "SUBJECT": "vx.azure.test.upload" +}