add-connector
Skill0 starsChanged 7 months agoMITView on GitHub
Add a new connector to the Azure Connectors Python SDK. USE WHEN: adding a new connector client, scaffolding connector files, creating unit tests, updating __init__.py exports, updating README status table, creating sample usage files. Covers the full workflow from connector file creation through test validation. NOT FOR: modifying existing connectors, connection setup, or trigger registration.
- Installs packages
2 other projects use a version of this.
Adopted by
Most recently taken up by
- microsoft/power-platform-skillstheir own version, first seen Oct 1, 2026
- Shayanrs31/pa-code-apps-claude-plugintheir own version, first seen Aug 17, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- microsoft/power-platform-skills★ 961same name
- Shayanrs31/pa-code-apps-claude-plugin★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- connection-setupSkill
- trigger-registrationSkill
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 3 are distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 42
Ensure the connector file exists at src/azure/connectors/{connector_name}.py.
- Very specific: line 84
Add the connector import to src/azure/connectors/__init__.py:
- Distinctive: line 97
Add a row to the "Validated Connectors" table in README.md:
- Very specific: line 107
Create tests/test_{connector_name}.py following this template:
- Very specific: line 344
Use async with for client lifecycle
- Very specific: line 349
Add a row to samples/sample_connector_usage/README.md:
- Very specific: line 359
Add the new connector to the [Unreleased] section in CHANGELOG.md under ### Added:
- Distinctive: line 369
If there are multiple new connectors being added together, combine them in a single bullet point:
- Very specific: line 378
Add the connector's API name to the supported SDK connector names list in .github/skills/connection-setup/SKILL.md (Step 2).
- Very specific: line 438
If the connector has undefined type references, the try/except wrapper handles it gracefully.
- Very specific: line 442
Ensure tests/__init__.py exists.
- Distinctive: line 446
Check that all imported types exist in the connector module.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Add New Connector Skill
Automates the complete workflow for adding a new connector to the Azure Connectors Python SDK.
When to Use
- Adding a completely new connector to the SDK
- Scaffolding all required files for a new connector
- Creating comprehensive unit tests for a new connector
- Creating sample usage files from .NET examples
Prerequisites
- The connector module file (e.g.,
dynamics365.py) is provided or needs to be created - The connector follows the
ConnectorClientBasepattern - A .NET sample exists to port to Python (optional)
Procedure
Step 1: Gather Connector Information
Collect the following details from the user:
| Field | Description | Example |
connector_name | Snake_case module name | dynamics365, servicenow |
client_class_name | PascalCase client class | Dynamics365Client, ServicenowClient |
display_name | Human-readable name | Dynamics 365, ServiceNow |
package_path | Import path | azure.connectors.dynamics365 |
env_var_name | Environment variable | DYNAMICS365_CONNECTION_URL |
status | Validation status | ✅ E2E Validated or 🔄 SDK Generated |
test_count | Number of tests | 30 tests |
Step 2: Create/Verify Connector Module
Ensure the connector file exists at src/azure/connectors/{connector_name}.py.
The connector must follow this structure:
# Copyright (c) Microsoft Corporation. All rights reserved.
# {ClientClassName}.py - Auto-generated DirectClient SDK
# Do not edit this file directly.
from __future__ import annotations
from dataclasses import dataclass, field
from typing import Optional, Any, Dict, List
from urllib.parse import quote
import json
from azure.connectors.sdk import (
ConnectorClientBase,
ConnectorClientOptions,
TokenProvider,
ManagedIdentityTokenProvider,
ConnectorException,
)
# Type Definitions
# ... dataclasses for request/response types ...
class {ClientClassName}(ConnectorClientBase):
"""Client for {DisplayName} connector operations."""
@property
def connector_name(self) -> str:
return "{connector_name}"
# ... async methods ...Step 3: Update __init__.py Exports
Add the connector import to src/azure/connectors/__init__.py:
try:
from .{connector_name} import {ClientClassName}
except (ImportError, NameError):
{ClientClassName} = None # type: ignore[assignment,misc]Also add to the __all__ list if present.
Step 4: Update README Connector Table
Add a row to the "Validated Connectors" table in README.md:
| **{DisplayName}** | `{package_path}` | ✅ Complete | {status} | {test_count} |Insert alphabetically by display name. Update the "Total:" line with the new test count.
Step 5: Create Unit Tests
Create tests/test_{connector_name}.py following this template:
# Copyright (c) Microsoft Corporation. All rights reserved.
"""Unit tests for {ClientClassName}."""
import pytest
from unittest.mock import AsyncMock, patch
from azure.connectors.{connector_name} import (
{ClientClassName},
# Import all public dataclasses from the connector
)
from azure.connectors.sdk import (
ConnectorClientOptions,
ManagedIdentityTokenProvider,
ConnectorException,
)
from tests.conftest import MockResponse
class Test{ClientClassName}Initialization:
"""Tests for {ClientClassName} initialization."""
def test_init_with_valid_url_and_defaults(self):
"""Test initialization with valid URL and default parameters."""
client = {ClientClassName}("https://example.azure.com/connections/test")
assert client._connection_runtime_url == "https://example.azure.com/connections/test"
assert client.connector_name == "{connector_name}"
assert isinstance(client._http_client._token_provider, ManagedIdentityTokenProvider)
def test_init_with_trailing_slash(self):
"""Test that trailing slash is removed from URL."""
client = {ClientClassName}("https://example.azure.com/connections/test/")
assert client._connection_runtime_url == "https://example.azure.com/connections/test"
def test_init_with_custom_token_provider(self, mock_token_provider):
"""Test initialization with custom token provider."""
client = {ClientClassName}(
"https://example.azure.com/connections/test",
token_provider=mock_token_provider
)
assert client._http_client._token_provider is mock_token_provider
def test_init_with_custom_options(self, mock_token_provider):
"""Test initialization with custom options."""
options = ConnectorClientOptions(timeout_seconds=60.0, max_retry_attempts=5)
client = {ClientClassName}(
"https://example.azure.com/connections/test",
token_provider=mock_token_provider,
options=options
)
assert client._options is options
assert client._options.timeout_seconds == 60.0
assert client._options.max_retry_attempts == 5
def test_init_with_empty_url_raises_error(self):
"""Test that empty URL raises ValueError."""
with pytest.raises(ValueError, match="connection_runtime_url cannot be None or empty"):
{ClientClassName}("")
def test_init_with_none_url_raises_error(self):
"""Test that None URL raises ValueError."""
with pytest.raises(ValueError, match="connection_runtime_url cannot be None or empty"):
{ClientClassName}(None)
def test_connector_name_property(self, mock_token_provider):
"""Test connector_name property returns '{connector_name}'."""
client = {ClientClassName}(
"https://example.azure.com/connections/test",
token_provider=mock_token_provider
)
assert client.connector_name == "{connector_name}"
class Test{ClientClassName}Lifecycle:
"""Tests for {ClientClassName} lifecycle methods."""
@pytest.mark.asyncio
async def test_close(self, mock_token_provider):
"""Test close method calls http_client.close."""
client = {ClientClassName}(
"https://example.azure.com/connections/test",
token_provider=mock_token_provider
)
with patch.object(client._http_client, 'close', new_callable=AsyncMock) as mock_close:
await client.close()
mock_close.assert_called_once()
@pytest.mark.asyncio
async def test_context_manager(self, mock_token_provider):
"""Test async context manager functionality."""
with patch.object({ClientClassName}, 'close', new_callable=AsyncMock) as mock_close:
async with {ClientClassName}(
"https://example.azure.com/connections/test",
token_provider=mock_token_provider
) as client:
assert isinstance(client, {ClientClassName})
mock_close.assert_called_once()
# Add test classes for each public method in the connector
# Follow the pattern:
#
# class Test{MethodName}:
# """Tests for {method_name}_async method."""
#
# @pytest.mark.asyncio
# async def test_success(self, mock_token_provider):
# """Test successful request."""
# ...
#
# @pytest.mark.asyncio
# async def test_error_response_raises_exception(self, mock_token_provider):
# """Test that error response raises ConnectorException."""
# ...Required test categories:
- Initialization tests — constructor, URL handling, options, error cases
- Lifecycle tests — close(), context manager
- Method tests — one class per public async method with:
- Success case with mocked response
- Parameter handling tests
- Error response handling
Step 6: Create Sample Usage File
Create samples/sample_connector_usage/sample_connector_usage_{connector_name}.py:
# Copyright (c) Microsoft Corporation. All rights reserved.
"""
{DisplayName} Connector SDK Sample
This sample demonstrates how to use the {DisplayName} connector SDK.
Prerequisites:
1. Azure subscription with {DisplayName} connection
2. {DisplayName} connection in Connector Namespaces
3. Connection runtime URL from Azure Portal
Installation:
pip install azure-connectors
Usage:
Set environment variable:
$env:{ENV_VAR_NAME} = "https://[region].azure-apihub.net/apim/{connector_name}/[connection-id]"
python sample_connector_usage_{connector_name}.py
"""
import asyncio
import os
from azure.identity.aio import DefaultAzureCredential
from azure.connectors import ConnectorException
from azure.connectors.{connector_name} import (
{ClientClassName},
# Import relevant dataclasses for the examples
)
# Connection runtime URL format:
# https://[region].azure-apihub.net/apim/{connector_name}/[connection-id]
CONNECTION_RUNTIME_URL = os.environ.get(
"{ENV_VAR_NAME}",
""
)
async def example_1_basic_operation():
"""Example 1: Basic connector operation."""
print("\n=== Example 1: Basic Operation ===")
credential = DefaultAzureCredential()
async with {ClientClassName}(CONNECTION_RUNTIME_URL, credential) as client:
try:
# Call a basic read operation
result = await client.{example_method}_async()
print(f"Result: {{result}}")
except ConnectorException as ex:
print(f"Connector error: {{ex}}")
except Exception as ex:
print(f"Error: {{ex}}")
async def example_2_advanced_operation():
"""Example 2: Advanced connector operation."""
print("\n=== Example 2: Advanced Operation ===")
credential = DefaultAzureCredential()
async with {ClientClassName}(CONNECTION_RUNTIME_URL, credential) as client:
try:
# Call a write or complex operation
# result = await client.{another_method}_async(...)
print("Advanced operation completed")
except ConnectorException as ex:
print(f"Connector error: {{ex}}")
except Exception as ex:
print(f"Error: {{ex}}")
async def main():
"""Run all examples."""
if not CONNECTION_RUNTIME_URL:
print("Error: {ENV_VAR_NAME} environment variable not set.")
print("Set it to your connection runtime URL from Azure Portal.")
return
print(f"Using connection URL: {{CONNECTION_RUNTIME_URL[:50]}}...")
await example_1_basic_operation()
await example_2_advanced_operation()
print("\n=== All examples completed ===")
if __name__ == "__main__":
asyncio.run(main())When porting from .NET:
- Find the corresponding .NET sample
- Translate each example method to Python async/await syntax
- Convert C# types to Python dataclasses
- Use
async withfor client lifecycle - Handle exceptions with
ConnectorException
Step 7: Update Samples README
Add a row to samples/sample_connector_usage/README.md:
| `sample_connector_usage_{connector_name}.py` | {DisplayName} | `{ENV_VAR_NAME}` |Insert alphabetically by connector name.
Step 8: Update CHANGELOG
Add the new connector to the [Unreleased] section in CHANGELOG.md under ### Added:
## [Unreleased]
### Added
- **{DisplayName}** (`{connector_name}.py`) connector client with unit tests and samplesIf there are multiple new connectors being added together, combine them in a single bullet point:
- **3 new connector clients** with unit tests and samples:
- {DisplayName}, Other Connector, Another ConnectorStep 9: Update Connection Setup Skill
Add the connector's API name to the supported SDK connector names list in .github/skills/connection-setup/SKILL.md (Step 2).
Find the line that starts with Supported SDK connector names: and add {connector_name} alphabetically to the list:
Supported SDK connector names: `arm`, `azuread`, ..., `{connector_name}`, ... (and any `Microsoft.Web/connections` connector name).Step 10: Run Tests
Execute the full test suite to validate:
.\.venv\Scripts\python -m pytest tests/test_{connector_name}.py tests/test_code_quality.py -v --tb=shortRequired checks:
- All tests pass
- No import errors
- Code quality tests pass (imports, structure)
Step 11: Validate Sample Syntax
python -m py_compile samples/sample_connector_usage/sample_connector_usage_{connector_name}.py
.\.venv\Scripts\python.exe -m flake8 samples/sample_connector_usage/sample_connector_usage_{connector_name}.py --max-line-length=100Checklist
Before completing, verify:
src/azure/connectors/{connector_name}.pyexists with proper structuresrc/azure/connectors/__init__.pyupdated with try/except importREADME.mdconnector table updated with correct status and test counttests/test_{connector_name}.pycreated with comprehensive testssamples/sample_connector_usage/sample_connector_usage_{connector_name}.pycreatedsamples/sample_connector_usage/README.mdupdatedCHANGELOG.mdupdated with new connector in[Unreleased]section.github/skills/connection-setup/SKILL.mdStep 2 updated with connector API name- All tests pass
- Sample file compiles without errors
Files Modified
| File | Change |
src/azure/connectors/{connector_name}.py | New connector module |
src/azure/connectors/__init__.py | Add export |
README.md | Add to connector table |
tests/test_{connector_name}.py | New test file |
samples/sample_connector_usage/sample_connector_usage_{connector_name}.py | New sample |
samples/sample_connector_usage/README.md | Add to samples table |
CHANGELOG.md | Add to [Unreleased] section |
.github/skills/connection-setup/SKILL.md | Add connector name to Step 2 |
Common Issues
Import Error in __init__.py
If the connector has undefined type references, the try/except wrapper handles it gracefully. The connector will be None until fixed.
Test Discovery
Ensure tests/__init__.py exists. Test files must start with test_.
Sample File Errors
Check that all imported types exist in the connector module. Use only public dataclasses.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

