Jalankan paket SSIS dengan aktivitas Eksekusi Paket SSIS di Azure Data Factory dengan PowerShell

BERLAKU UNTUK:Azure Data Factory Azure Synapse Analytics

Tip

Cobalah Data Factory di Microsoft Fabric, solusi analitik all-in-one untuk perusahaan. Microsoft Fabric mencakup semuanya mulai dari pergerakan data hingga ilmu data, analitik real time, kecerdasan bisnis, dan pelaporan. Pelajari cara memulai uji coba baru secara gratis!

Artikel ini menjelaskan cara menjalankan paket SQL Server Integration Services (SSIS) di alur Azure Data Factory menggunakan PowerShell dan aktivitas Eksekusi Paket SSIS.

Prasyarat

Catatan

Sebaiknya Anda menggunakan modul Azure Az PowerShell untuk berinteraksi dengan Azure. Lihat Menginstal Azure PowerShell untuk memulai. Untuk mempelajari cara bermigrasi ke modul Az PowerShell, lihat Memigrasikan Azure PowerShell dari AzureRM ke Az.

Buat Runtime integrasi (IR) Azure-SSIS jika Anda belum memilikinya dengan mengikuti instruksi langkah demi langkah dalam Tutorial: Menyediakan Runtime integrasi Azure-SSIS.

Membuat pabrik data dengan Runtime integrasi Azure-SSIS

Anda dapat menggunakan pabrik data yang sudah ada yang telah menyediakan Runtime integrasi Azure-SSIS atau membuat pabrik data baru dengan Runtime integrasi Azure-SSIS. Ikuti instruksi langkah demi langkah dalam Tutorial: Menerapkan paket SSIS ke Azure melalui PowerShell.

Membuat alur dengan aktivitas Eksekusi Paket SSIS

Dalam langkah ini, Anda membuat alur dengan aktivitas Eksekusi Paket SSIS. Aktivitas menjalankan paket SSIS Anda.

  1. Buat file JSON bernama RunSSISPackagePipeline.json dalam folder C:\ADF\RunSSISPackage dengan konten yang mirip dengan contoh berikut.

    Penting

    Ganti nama objek, deskripsi, dan jalur, nilai properti atau parameter, kata sandi, dan nilai variabel lainnya sebelum Anda menyimpan file.

    {
        "name": "RunSSISPackagePipeline",
        "properties": {
            "activities": [{
                "name": "MySSISActivity",
                "description": "My SSIS package/activity description",
                "type": "ExecuteSSISPackage",
                "typeProperties": {
                    "connectVia": {
                        "referenceName": "MyAzureSSISIR",
                        "type": "IntegrationRuntimeReference"
                    },
                    "executionCredential": {
                        "domain": "MyExecutionDomain",
                        "username": "MyExecutionUsername",
                        "password": {
                            "type": "SecureString",
                            "value": "MyExecutionPassword"
                        }
                    },
                    "runtime": "x64",
                    "loggingLevel": "Basic",
                    "packageLocation": {
                        "type": "SSISDB",
                        "packagePath": "MyFolder/MyProject/MyPackage.dtsx"
                    },
                    "environmentPath": "MyFolder/MyEnvironment",
                    "projectParameters": {
                        "project_param_1": {
                            "value": "123"
                        },
                        "project_param_2": {
                            "value": {
                                "value": "@pipeline().parameters.MyProjectParameter",
                                "type": "Expression"
                            }
                        }
                    },
                    "packageParameters": {
                        "package_param_1": {
                            "value": "345"
                        },
                        "package_param_2": {
                            "value": {
                                "type": "AzureKeyVaultSecret",
                                "store": {
                                    "referenceName": "myAKV",
                                    "type": "LinkedServiceReference"
                                },
                                "secretName": "MyPackageParameter"
                            }
                        }
                    },
                    "projectConnectionManagers": {
                        "MyAdonetCM": {
                            "username": {
                                "value": "MyConnectionUsername"
                            },
                            "password": {
                                "value": {
                                    "type": "SecureString",
                                    "value": "MyConnectionPassword"
                                }
                            }
                        }
                    },
                    "packageConnectionManagers": {
                        "MyOledbCM": {
                            "username": {
                                "value": {
                                    "value": "@pipeline().parameters.MyConnectionUsername",
                                    "type": "Expression"
                                }
                            },
                            "password": {
                                "value": {
                                    "type": "AzureKeyVaultSecret",
                                    "store": {
                                        "referenceName": "myAKV",
                                        "type": "LinkedServiceReference"
                                    },
                                    "secretName": "MyConnectionPassword",
                                    "secretVersion": "MyConnectionPasswordVersion"
                                }
                            }
                        }
                    },
                    "propertyOverrides": {
                        "\\Package.MaxConcurrentExecutables": {
                            "value": 8,
                            "isSensitive": false
                        }
                    }
                },
                "policy": {
                    "timeout": "0.01:00:00",
                    "retry": 0,
                    "retryIntervalInSeconds": 30
                }
            }]
        }
    }
    

    Untuk menjalankan paket yang disimpan dalam sistem file/Azure Files, masukkan nilai untuk properti lokasi paket dan log Anda sebagai berikut:

    {
        {
            {
                {
                    "packageLocation": {
                        "type": "File",
                        "packagePath": "//MyStorageAccount.file.core.windows.net/MyFileShare/MyPackage.dtsx",
                        "typeProperties": {
                            "packagePassword": {
                                "type": "SecureString",
                                "value": "MyEncryptionPassword"
                            },
                            "accessCredential": {
                                "domain": "Azure",
                                "username": "MyStorageAccount",
                                "password": {
                                    "type": "SecureString",
                                    "value": "MyAccountKey"
                                }
                            }
                        }
                    },
                    "logLocation": {
                        "type": "File",
                        "logPath": "//MyStorageAccount.file.core.windows.net/MyFileShare/MyLogFolder",
                        "typeProperties": {
                            "accessCredential": {
                                "domain": "Azure",
                                "username": "MyStorageAccount",
                                "password": {
                                    "type": "AzureKeyVaultSecret",
                                    "store": {
                                        "referenceName": "myAKV",
                                        "type": "LinkedServiceReference"
                                    },
                                    "secretName": "MyAccountKey"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    

    Untuk menjalankan paket dalam proyek yang disimpan dalam sistem file/Azure Files, masukkan nilai untuk properti lokasi paket Anda sebagai berikut:

    {
        {
            {
                {
                    "packageLocation": {
                        "type": "File",
                        "packagePath": "//MyStorageAccount.file.core.windows.net/MyFileShare/MyProject.ispac:MyPackage.dtsx",
                        "typeProperties": {
                            "packagePassword": {
                                "type": "SecureString",
                                "value": "MyEncryptionPassword"
                            },
                            "accessCredential": {
                                "domain": "Azure",
                                "userName": "MyStorageAccount",
                                "password": {
                                    "type": "SecureString",
                                    "value": "MyAccountKey"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    

    Untuk menjalankan paket tersemat, masukkan nilai untuk properti lokasi paket Anda sebagai berikut:

    {
        {
            {
                {
                    "packageLocation": {
                        "type": "InlinePackage",
                        "typeProperties": {
                            "packagePassword": {
                                "type": "SecureString",
                                "value": "MyEncryptionPassword"
                            },
                            "packageName": "MyPackage.dtsx",
                            "packageContent":"My compressed/uncompressed package content",
                            "packageLastModifiedDate": "YYYY-MM-DDTHH:MM:SSZ UTC-/+HH:MM"
                        }
                    }
                }
            }
        }
    }
    

    Untuk menjalankan paket yang disimpan dalam penyimpanan paket, masukkan nilai untuk properti lokasi paket dan konfigurasi Anda sebagai berikut:

    {
        {
            {
                {
                    "packageLocation": {
                        "type": "PackageStore",
                        "packagePath": "myPackageStore/MyFolder/MyPackage",
                        "typeProperties": {
                            "packagePassword": {
                                "type": "SecureString",
                                "value": "MyEncryptionPassword"
                            },
                            "accessCredential": {
                                "domain": "Azure",
                                "username": "MyStorageAccount",
                                "password": {
                                    "type": "SecureString",
                                    "value": "MyAccountKey"
                                }
                            },
                            "configurationPath": "//MyStorageAccount.file.core.windows.net/MyFileShare/MyConfiguration.dtsConfig",
                            "configurationAccessCredential": {
                                "domain": "Azure",
                                "userName": "MyStorageAccount",
                                "password": {
                                    "type": "AzureKeyVaultSecret",
                                    "store": {
                                        "referenceName": "myAKV",
                                        "type": "LinkedServiceReference"
                                    },
                                    "secretName": "MyAccountKey"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    
  2. Di Azure PowerShell, beralihlah ke folder C:\ADF\RunSSISPackage.

  3. Untuk membuat alur RunSSISPackagePipeline, jalankan cmdlet Set-AzDataFactoryV2Pipeline.

    $DFPipeLine = Set-AzDataFactoryV2Pipeline -DataFactoryName $DataFactory.DataFactoryName `
                                                   -ResourceGroupName $ResGrp.ResourceGroupName `
                                                   -Name "RunSSISPackagePipeline"
                                                   -DefinitionFile ".\RunSSISPackagePipeline.json"
    

    Berikut sampel outputnya:

    PipelineName      : Adfv2QuickStartPipeline
    ResourceGroupName : <resourceGroupName>
    DataFactoryName   : <dataFactoryName>
    Activities        : {CopyFromBlobToBlob}
    Parameters        : {[inputPath, Microsoft.Azure.Management.DataFactory.Models.ParameterSpecification], [outputPath, Microsoft.Azure.Management.DataFactory.Models.ParameterSpecification]}
    

Menjalankan alur

Gunakan cmdlet Invoke-AzDataFactoryV2Pipeline untuk menjalankan alur. Cmdlet menampilkan ID eksekusi alur untuk pemantauan di masa mendatang.

$RunId = Invoke-AzDataFactoryV2Pipeline -DataFactoryName $DataFactory.DataFactoryName `
                                             -ResourceGroupName $ResGrp.ResourceGroupName `
                                             -PipelineName $DFPipeLine.Name

Monitor saluran pipa

Jalankan skrip PowerShell berikut ini untuk terus memeriksa status eksekusi alur hingga selesai menyalin data. Salin atau tempel skrip berikut di jendela PowerShell, dan pilih Enter.

while ($True) {
    $Run = Get-AzDataFactoryV2PipelineRun -ResourceGroupName $ResGrp.ResourceGroupName `
                                               -DataFactoryName $DataFactory.DataFactoryName `
                                               -PipelineRunId $RunId

    if ($Run) {
        if ($run.Status -ne 'InProgress') {
            Write-Output ("Pipeline run finished. The status is: " +  $Run.Status)
            $Run
            break
        }
        Write-Output  "Pipeline is running...status: InProgress"
    }

    Start-Sleep -Seconds 10
}   

Anda juga dapat memantau alur dengan menggunakan portal Microsoft Azure. Untuk instruksi langkah demi langkah, lihat Memantau alur.

Menjadwalkan alur dengan pemicu

Pada langkah sebelumnya, Anda menjalankan alur sesuai permintaan. Anda juga dapat membuat pemicu jadwal untuk menjalankan alur pada jadwal, seperti per jam atau harian.

  1. Buat file JSON bernama MyTrigger.json dalam folder C:\ADF\RunSSISPackage dengan konten berikut:

    {
        "properties": {
            "name": "MyTrigger",
            "type": "ScheduleTrigger",
            "typeProperties": {
                "recurrence": {
                    "frequency": "Hour",
                    "interval": 1,
                    "startTime": "2017-12-07T00:00:00-08:00",
                    "endTime": "2017-12-08T00:00:00-08:00"
                }
            },
            "pipelines": [{
                "pipelineReference": {
                    "type": "PipelineReference",
                    "referenceName": "RunSSISPackagePipeline"
                },
                "parameters": {}
            }]
        }
    }    
    
  2. Di Azure PowerShell, beralihlah ke folder C:\ADF\RunSSISPackage.

  3. Jalankan cmdlet Set-AzDataFactoryV2Trigger, yang membuat pemicu.

    Set-AzDataFactoryV2Trigger -ResourceGroupName $ResGrp.ResourceGroupName `
                                    -DataFactoryName $DataFactory.DataFactoryName `
                                    -Name "MyTrigger" -DefinitionFile ".\MyTrigger.json"
    
  4. Secara default, pemicu dalam status berhenti. Mulai pemicu dengan menjalankan cmdlet Start-AzDataFactoryV2Trigger.

    Start-AzDataFactoryV2Trigger -ResourceGroupName $ResGrp.ResourceGroupName `
                                      -DataFactoryName $DataFactory.DataFactoryName `
                                      -Name "MyTrigger" 
    
  5. Konfirmasikan bahwa pemicu dimulai dengan menjalankan cmdlet Get-AzDataFactoryV2Trigger.

    Get-AzDataFactoryV2Trigger -ResourceGroupName $ResourceGroupName `
                                    -DataFactoryName $DataFactoryName `
                                    -Name "MyTrigger"     
    
  6. Jalankan perintah berikut setelah satu jam berikutnya. Misalnya, jika waktu saat ini adalah 15.25 UTC, jalankan perintah pada pukul 16.00 UTC.

    Get-AzDataFactoryV2TriggerRun -ResourceGroupName $ResourceGroupName `
                                       -DataFactoryName $DataFactoryName `
                                       -TriggerName "MyTrigger" `
                                       -TriggerRunStartedAfter "2017-12-06" `
                                       -TriggerRunStartedBefore "2017-12-09"
    

    Jalankan kueri berikut ini terhadap database SSISDB di server SQL Anda untuk memverifikasi bahwa paket tersebut dijalankan.

    select * from catalog.executions