Need help on setting up Env variable in Azure Synapse Analytics Spark cluster

Shikhil Kumar Gupta MSFT 41 Reputation points
2022-01-04T13:34:07.76+00:00

Hi Team, I have dev, ppe and prod Azure Synapse analytics workspace. I will be deploying my jar for some computation. Now I need to insert the ENV variable for ppe, prod and dev enviorment. So that my jar running in spark cluster can refer env variable value and based on it, it can load dev, ppe or prod config. But I am unable to find out how to pass custom env variable for Synapse workspace.

Can you guys help me to know that?

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,037 questions
{count} votes

Accepted answer
  1. PRADEEPCHEEKATLA 90,246 Reputation points
    2022-01-05T12:05:01.29+00:00

    Hello @Shikhil Kumar Gupta MSFT ,

    Thanks for the question and using the MS Q&A platform.

    You can read custom config values in a spark notebook as shown below.

    Step1: Add your key-value pairs inside the config.txt file:

    spark.executorEnv.environmentName ppe  
    

    Step2: You can upload a config file to your spark pool.

    162552-image.png

    Step3: Which you are then able to access inside your notebooks:

    envName: str = spark.sparkContext.environment.get('environmentName', 'get')  
    

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.