Adf validation rules

From JosiahSiegel/claude-plugin-marketplace · View interactive version

Adf validation rules is an AI agent skill from the GitHub repository JosiahSiegel/claude-plugin-marketplace. ADF activity nesting rules, limits, and validation gotchas. PROACTIVELY activate for: (1) ADF activity nesting rules (ForEach inside If, Switch, Until), (2) ForEach limitations (no nested ForEach, item limits), (3) pipeline validation errors and ARM-template build failures, (4) linked service authen

How to use this skill

Skill file

Azure Data Factory Validation Rules and Limitations

🚨 CRITICAL: Activity Nesting Limitations

Azure Data Factory has STRICT nesting rules for control flow activities. Violating these rules will cause pipeline failures or prevent pipeline creation.

Supported Control Flow Activities for Nesting

Four control flow activities support nested activities:

✅ PERMITTED Nesting Combinations

| Parent Activity | Can Contain | Notes |

|----------------|-------------|-------|

| ForEach | If Condition | ✅ Allowed |

| ForEach | Switch | ✅ Allowed |

| Until | If Condition | ✅ Allowed |

| Until | Switch | ✅ Allowed |

❌ PROHIBITED Nesting Combinations

| Parent Activity | CANNOT Contain | Reason |

|----------------|----------------|---------|

| If Condition | ForEach | ❌ Not supported - use Execute Pipeline workaround |

| If Condition | Switch | ❌ Not supported - use Execute Pipeline workaround |

| If Condition | Until | ❌ Not supported - use Execute Pipeline workaround |

| If Condition | Another If | ❌ Cannot nest If within If |

| Switch | ForEach | ❌ Not supported - use Execute Pipeline workaround |

| Switch | If Condition | ❌ Not supported - use Execute Pipeline workaround |

| Switch | Until | ❌ Not supported - use Execute Pipeline workaround |

| Switch | Another Switch | ❌ Cannot nest Switch within Switch |

| ForEach | Another ForEach | ❌ Single level only - use Execute Pipeline workaround |

| Until | Another Until | ❌ Single level only - use Execute Pipeline workaround |

| ForEach | Until | ❌ Single level only - use Execute Pipeline workaround |

| Until | ForEach | ❌ Single level only - use Execute Pipeline workaround |

🚫 Special Activity Restrictions

Validation Activity:

🔧 Workaround: Execute Pipeline Pattern

The ONLY supported workaround for prohibited nesting combinations:

Instead of direct nesting, use the Execute Pipeline Activity to call a child pipeline:

{
  "name": "ParentPipeline_WithIfCondition",
  "activities": [
    {
      "name": "IfCondition_Parent",
      "type": "IfCondition",
      "typeProperties": {
        "expression": "@equals(pipeline().parameters.ProcessData, 'true')",
        "ifTrueActivities": [
          {
            "name": "ExecuteChildPipeline_WithForEach",
            "type": "ExecutePipeline",
            "typeProperties": {
              "pipeline": {
                "referenceName": "ChildPipeline_ForEachLoop",
                "type": "PipelineReference"
              },
              "parameters": {
                "ItemList": "@pipeline().parameters.Items"
              }
            }
          }
        ]
      }
    }
  ]
}

Child Pipeline Structure:

{
  "name": "ChildPipeline_ForEachLoop",
  "parameters": {
    "ItemList": {"type": "array"}
  },
  "activities": [
    {
      "name": "ForEach_InChildPipeline",
      "type": "ForEach",
      "typeProperties": {
        "items": "@pipeline().parameters.ItemList",
        "activities": [
          // Your ForEach logic here
        ]
      }
    }
  ]
}

Why This Works:

🔢 Activity and Resource Limits

Pipeline Limits

| Resource | Limit | Notes |

|----------|-------|-------|

| Activities per pipeline | 80 | Includes inner activities for containers |

| Parameters per pipeline | 50 | - |

| ForEach concurrent iterations | 50 (maximum) | Set via batchCount property |

| ForEach items | 100,000 | - |

| Lookup activity rows | 5,000 | Maximum rows returned |

| Lookup activity size | 4 MB | Maximum size of returned data |

| Web activity timeout | 1 hour | Default timeout for Web activities |

| Copy activity timeout | 7 days | Maximum execution time |

ForEach Activity Configuration

{
  "name": "ForEachActivity",
  "type": "ForEach",
  "typeProperties": {
    "items": "@pipeline().parameters.ItemList",
    "isSequential": false,  // false = parallel execution
    "batchCount": 50,       // Max 50 concurrent iterations
    "activities": [
      // Nested activities
    ]
  }
}

Critical Considerations:

Set Variable Activity Limitations

❌ CANNOT use Set Variable inside ForEach with isSequential: false

📊 Linked Services Validation (Azure Blob, Azure SQL)

Detailed validation rules and templates for ADF Linked Services (Azure Blob Storage and Azure SQL Database) — auth types (key, SAS, managed identity, AAD), network configuration, and connection-string patterns — live in references/linked-services.md. Load that reference when authoring or validating a Linked Service JSON.

🔍 Data Flow Limitations

General Limits

Transformation-Specific Limits

| Transformation | Limitation |

|----------------|------------|

| Lookup | Cache size limited by cluster memory |

| Join | Large joins may cause memory errors |

| Pivot | Maximum 10,000 unique values |

| Window | Requires partitioning for large datasets |

Performance Considerations

🛡️ Validation Checklist for Pipeline Creation

Before Creating Pipeline

Linked Service Validation

Activity Configuration Validation

Data Flow Validation

🔍 Automated Validation Script

CRITICAL: Always run automated validation before committing or deploying ADF pipelines!

The adf-master plugin includes a comprehensive PowerShell validation script that checks for ALL the rules and limitations documented above.

Using the Validation Script

Location: ${CLAUDE_PLUGIN_ROOT}/scripts/validate-adf-pipelines.ps1

Basic usage:

# From the root of your ADF repository
pwsh -File validate-adf-pipelines.ps1

With custom paths:

pwsh -File validate-adf-pipelines.ps1 `
    -PipelinePath "path/to/pipeline" `
    -DatasetPath "path/to/dataset"

With strict mode (additional warnings):

pwsh -File validate-adf-pipelines.ps1 -Strict

What the Script Validates

The automated validation script checks for issues that Microsoft's official @microsoft/azure-data-factory-utilities package does NOT validate:

  1. Activity Nesting Violations:
  1. Resource Limits:
  1. Variable Scope Violations:
  1. Dataset Configuration Issues:
  1. Copy Activity Validations:

Integration with CI/CD

GitHub Actions example:

- name: Validate ADF Pipelines
  run: |
    pwsh -File validate-adf-pipelines.ps1 -PipelinePath pipeline -DatasetPath dataset
  shell: pwsh

Azure DevOps example:

- task: PowerShell@2
  displayName: 'Validate ADF Pipelines'
  inputs:
    filePath: 'validate-adf-pipelines.ps1'
    arguments: '-PipelinePath pipeline -DatasetPath dataset'
    pwsh: true

Command Reference

Use the /adf-validate command to run the validation script with proper guidance:

/adf-validate

This command will:

  1. Detect your ADF repository structure
  2. Run the validation script with appropriate paths
  3. Parse and explain any errors or warnings found
  4. Provide specific solutions for each violation
  5. Recommend next actions based on results
  6. Suggest CI/CD integration patterns

Exit Codes

Best Practices

  1. Run validation before every commit to catch issues early
  2. Add validation to CI/CD pipeline to prevent invalid deployments
  3. Use strict mode during development for additional warnings
  4. Re-validate after bulk changes or generated pipelines
  5. Document validation exceptions if you must bypass a warning
  6. Share validation results with team to prevent repeated mistakes

🚨 CRITICAL: Enforcement Protocol

When creating or modifying ADF pipelines:

  1. ALWAYS validate activity nesting against the permitted/prohibited table
  2. REJECT any attempt to create prohibited nesting combinations
  3. SUGGEST Execute Pipeline workaround for complex nesting needs
  4. VALIDATE linked service authentication matches the connector type
  5. CHECK all limits (activities, parameters, ForEach iterations, etc.)
  6. VERIFY required properties are set (e.g., accountKind for managed identity)
  7. WARN about common pitfalls specific to the connector being used

Example Validation Response:

❌ INVALID PIPELINE STRUCTURE DETECTED:

Issue: ForEach activity contains another ForEach activity
Location: Pipeline "PL_DataProcessing" → ForEach "OuterLoop" → ForEach "InnerLoop"

This violates Azure Data Factory nesting rules:
- ForEach activities support only a SINGLE level of nesting
- You CANNOT nest ForEach within ForEach

✅ RECOMMENDED SOLUTION:
Use the Execute Pipeline pattern:
1. Create a child pipeline with the inner ForEach logic
2. Replace the inner ForEach with an Execute Pipeline activity
3. Pass required parameters to the child pipeline

Would you like me to generate the refactored pipeline structure?

📚 Reference Documentation

Official Microsoft Learn Resources:

Last Updated: 2025-01-24 (Based on official Microsoft documentation)

This validation rules skill MUST be consulted before creating or modifying ANY Azure Data Factory pipeline to ensure compliance with platform limitations and best practices.

Progressive Disclosure References

For detailed validation matrices and resource limits, see:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.