Search code examples
azure-devopsazure-synapse

How to have dynamically the environment value in each environment of Synapse?


In Azure I work with Azure Synapse Analytics. I have a Synapse Analytics by environment. Once I have finished my pipeline in development environment I have a release pipeline in devops that deploy to preprod env.

Problem is that in my notebooks I have the following parameter : "env" used in this path path = f'abfss://bronze@synapse{env}.dfs.core.windows.net'

Parameter env is in a json that I give in the Parameters tab in Synapse.

My pipeline in preprod fail because in notebook the path is `path = f'abfss://[email protected]'

How can I do to dynamically have the env value in each environment ? I don't want to change it manually because there is a release pipeline in devops.


Solution

  • You can use mssparkutils to get the name of the current environment, instead of pooling it from a parameter:

    mssparkutils.env.getWorkspaceName()
    

    Documentation: https://learn.microsoft.com/en-us/azure/synapse-analytics/spark/microsoft-spark-utilities?pivots=programming-language-python#environment-utilities