Azure / Azure-DataFactory

Other
485 stars 591 forks source link

Exclude Managed Private Endpoints from ARM Template Export #657

Open joshwright10 opened 7 months ago

joshwright10 commented 7 months ago

Problem

The ARM Template exported from Data Factory using the Git integration includes the Managed Private Endpoint resources. As these Private Endpoints are environment specific, these should not be promoted to other environments and should be excluded from the ARM template. In the current state, all MPEs are propagated up to UAT and Production, meaning that the UAT and Production Data Factory instances try to create Managed Private Endpoints to the DEV SQL and Cosmos DB Account.

Our Terraform instances are provisioned via Terraform, and Managed Private Endpoints are configured there, with DEV connections to DEV resources (SQL Servers, Storage Accounts, Key Vaults, Cosmos DB etc.), UAT to UAT resources and Production to Production resources.

A stripped-down version of the ARM Template

{
    "name": "[concat(parameters('factoryName'), '/default')]",
    "type": "Microsoft.DataFactory/factories/managedVirtualNetworks",
    "apiVersion": "2018-06-01",
    "properties": {},
    "dependsOn": []
},
{
    "name": "[concat(parameters('factoryName'), '/default/cosmosdb-dev01-server01-CosmosDb-Sql')]",
    "type": "Microsoft.DataFactory/factories/managedVirtualNetworks/managedPrivateEndpoints",
    "apiVersion": "2018-06-01",
    "properties": {
        "privateLinkResourceId": "[parameters('cosmosdb-dev01-server01-CosmosDb-Sql_properties_privateLinkResourceId')]",
        "groupId": "[parameters('cosmosdb-dev01-server01-CosmosDb-Sql_properties_groupId')]",
        "fqdns": "[parameters('cosmosdb-dev01-server01-CosmosDb-Sql_properties_fqdns')]"
    },
    "dependsOn": [
        "[concat(variables('factoryId'), '/managedVirtualNetworks/default')]"
    ]
},
{
    "name": "[concat(parameters('factoryName'), '/default/sql-dev01-server01-SqlServer-sqlServer')]",
    "type": "Microsoft.DataFactory/factories/managedVirtualNetworks/managedPrivateEndpoints",
    "apiVersion": "2018-06-01",
    "properties": {
        "privateLinkResourceId": "[parameters('sql-dev01-server01-SqlServer-sqlServer_properties_privateLinkResourceId')]",
        "groupId": "[parameters('sql-dev01-server01-SqlServer-sqlServer_properties_groupId')]",
        "fqdns": "[parameters('sql-dev01-server01-SqlServer-sqlServer_properties_fqdns')]"
    },
    "dependsOn": [
        "[concat(variables('factoryId'), '/managedVirtualNetworks/default')]"
    ]
}

We are using this document Sample pre- and post-deployment script to promote changes from development through to production. The workflow looks like this:

Solution