This package is built on top of this repository. I have enhanced it to be more suitable for Azure Pipelines and Added New Fuctions for DevOps Pipeline Activies.
This package is designed to be used within an Azure DevOps Pipeline to update a Fabric Workspace from a Git repository using a user with an email and password. It supports both public client and confidential client applications. For more information about the differences, click here
Note This is currently the only available method because Microsoft does not support service principals for these operations. Once it becomes available, please use it. For more information, check Microsoft Entra supported identities here.
Another method is to schedule a notebook on Fabric running under the authority of a user who is a contributor or higher in an administration workspace using this libirary.
To install the package, use the following command:
pip install fabricops
you can add the following tasks in your azure-pipeline.yml
to create the files
- bash: 'python -m pip install fabricops --no-cache-dir --upgrade'
displayName: 'Install FabricOps'
- task: PythonScript@0
displayName: 'Create Config File'
inputs:
scriptSource: 'filePath'
scriptPath: '$(Build.SourcesDirectory)/create_configs.py'
arguments: '--WORKSPACE_ID $(WORKSPACE_ID) --WORKSPACE_WH_ID $(WORKSPACE_WH_ID) --CLIENT_ID $(CLIENTID) --TENANT_ID $(TENANTID) --USER_NAME $(email) --PASSWORD $(password) --CLIENT_SECRET $(CLIENTSECRET)'
workingDirectory: '$(Build.SourcesDirectory)'
# Step 3: Publish the file as a pipeline artifact
- task: PublishPipelineArtifact@1
inputs:
targetPath: 'linkedservice-config.json'
artifact: 'config-file'
displayName: 'Publish created file as artifact'
- task: DownloadPipelineArtifact@2
inputs:
artifact: 'config-file'
path: '$(Pipeline.Workspace)'
displayName: 'Download created file'
and the content of create_configs.py
exists in the Samples Folder.
you can use the following task
- script: |
python3 -c "from fabricops import update_linked_services; update_linked_services('$(Pipeline.Workspace)/linkedservice-config.json', '$(Build.SourcesDirectory)')"
displayName: 'PY Modify JSON Files'
Now you can update your Fabric Workspace From connected Repo. update.py
in samples Folder
- task: PythonScript@0
displayName: 'Run a Python script'
inputs:
scriptSource: 'filePath'
scriptPath: '$(Build.SourcesDirectory)/update.py'
arguments: '--WORKSPACE_ID $(WORKSPACE_ID) --CLIENT_ID $(CLIENTID) --TENANT_ID $(TENANTID) --USER_NAME $(email) --PASSWORD $(password) --CLIENT_SECRET $(CLIENTSECRET)'
workingDirectory: '$(Build.SourcesDirectory)'