<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Environment File in Notebook in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4611626#M7948</link>
    <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/882992"&gt;@v-hashadapu&lt;/a&gt;&amp;nbsp; how are you getting getVariable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smpa01_0-1742094497588.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1250780i549DD444FEF09E21/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smpa01_0-1742094497588.png" alt="smpa01_0-1742094497588.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 16 Mar 2025 03:08:43 GMT</pubDate>
    <dc:creator>smpa01</dc:creator>
    <dc:date>2025-03-16T03:08:43Z</dc:date>
    <item>
      <title>Environment File in Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4366293#M6140</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do we attached ENV file to the notebooks when migrating through both deployment pipeline and devops.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 04:38:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4366293#M6140</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-16T04:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Environment File in Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4366558#M6145</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this what you are looking for?&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/data-engineering/environment-git-and-deployment-pipeline#deployment-pipeline-for-environment" target="_blank"&gt;https://learn.microsoft.com/en-us/fabric/data-engineering/environment-git-and-deployment-pipeline#deployment-pipeline-for-environment&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 06:39:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4366558#M6145</guid>
      <dc:creator>govindarajan_d</dc:creator>
      <dc:date>2025-01-16T06:39:55Z</dc:date>
    </item>
    <item>
      <title>Re: Environment File in Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4371405#M6230</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Microsoft Fabric does not have native support for attaching .env files directly to notebooks when migrating through deployment pipelines or DevOps. However, there are a few approaches you can consider for managing environment variables and secrets in Fabric notebooks:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Use NotebookUtils: Fabric provides NotebookUtils for working with environment variables. You can use the following code to access environment variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;from notebookutils import mssparkutils&lt;/P&gt;&lt;P&gt;# Get an environment variable&lt;BR /&gt;value = mssparkutils.env.getVariable("VARIABLE_NAME")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Deployment Rules: When using deployment pipelines, you can create deployment rules to parameterize certain values, such as the default lakehouse, for each notebook instance. This allows you to change specific configurations when deploying across different environments.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Environment Resources: Fabric notebooks support an Environment Resources folder, which is a shared repository for collaboration across multiple notebooks. You could potentially store configuration files here, although it’s not recommended for sensitive information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please accept this solution and give kudos if this is helpful.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;Nilendra&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 08:33:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4371405#M6230</guid>
      <dc:creator>nilendraFabric</dc:creator>
      <dc:date>2025-01-20T08:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: Environment File in Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4372521#M6279</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to call fabric env files which has built in libraries and allows public/custom libraries.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 23:42:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4372521#M6279</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-20T23:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Environment File in Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4385872#M6650</link>
      <description>&lt;P&gt;Hi @Anonymous&lt;/a&gt;&amp;nbsp;, thank you for reaching out to the Microsoft Fabric Community Forum.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Microsoft Fabric does not natively support attaching .env files to notebooks. However, you can manage environment variables in different ways:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Fabric provides NotebookUtils (mssparkutils), which allows you to store and retrieve environment variables but this works only for variables already configured in Fabric.:&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;from notebookutils import mssparkutils&lt;/P&gt;
&lt;P&gt;# Get an environment variable&lt;/P&gt;
&lt;P&gt;value = mssparkutils.env.getVariable("MY_ENV_VAR")&lt;/P&gt;
&lt;P&gt;print(value)&lt;/P&gt;
&lt;OL start="2"&gt;
&lt;LI&gt;If you need to customize values per environment (Dev, Test, Prod), you can use Deployment Rules but this is not a direct .env file solution.:&lt;/LI&gt;
&lt;LI&gt;Navigate to Deployment Pipelines.&lt;/LI&gt;
&lt;LI&gt;Create a Deployment Rule to set specific values.&lt;/LI&gt;
&lt;LI&gt;This allows modifying Lakehouse paths, parameters, etc. dynamically.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL start="3"&gt;
&lt;LI&gt;Store a .env File in a Lakehouse and Read It in the Notebook. This works for custom environment variables but less secure if the .env file contains sensitive data:&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;BR /&gt;import os&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;# Read .env file from Lakehouse Files&lt;/P&gt;
&lt;P&gt;file_path = "/lakehouse/default/Files/config/.env"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;with open(file_path, "r") as f:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for line in f:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; key, value = line.strip().split("=")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.environ[key] = value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;# Access an environment variable&lt;/P&gt;
&lt;P&gt;print(os.getenv("MY_CUSTOM_VAR"))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL start="4"&gt;
&lt;LI&gt;If your .env file contains API keys, credentials, or secrets, store them in Azure Key Vault and retrieve them in your notebook. This way you can have Secure credentials &amp;amp; secrets but Requires Azure Key Vault setup&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;from notebookutils import mssparkutils&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;# Get a secret from Azure Key Vault&lt;/P&gt;
&lt;P&gt;secret_value = mssparkutils.credentials.getSecret("my-key-vault", "MY_SECRET_KEY")&lt;/P&gt;
&lt;P&gt;print(secret_value)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this helps, please consider marking it &lt;STRONG&gt;'Accept as Solution'&lt;/STRONG&gt; so others with similar queries may find it more easily. If not, please share the details.&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Jan 2025 10:05:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4385872#M6650</guid>
      <dc:creator>v-hashadapu</dc:creator>
      <dc:date>2025-01-29T10:05:45Z</dc:date>
    </item>
    <item>
      <title>Re: Environment File in Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4392592#M6865</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&lt;/a&gt;&amp;nbsp;, Hope your issue is solved. If it is, please consider marking the answer 'Accept as solution', so others with similar issues may find it easily. If it isn't, please share the details. &lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Feb 2025 14:01:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4392592#M6865</guid>
      <dc:creator>v-hashadapu</dc:creator>
      <dc:date>2025-02-03T14:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: Environment File in Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4393213#M6890</link>
      <description>&lt;P&gt;Wanted specifically on how to re-tag different env in notebook. eg. lakehouse can be specified in deployment rules, but I don't see it for env object (not unix env)&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 00:14:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4393213#M6890</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-02-04T00:14:06Z</dc:date>
    </item>
    <item>
      <title>Re: Environment File in Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4393662#M6901</link>
      <description>&lt;P&gt;Hi @Anonymous&lt;/a&gt;&amp;nbsp;, thank you for reaching out to the Microsoft Fabric Community Forum.&lt;/P&gt;
&lt;P&gt;To attach an ENV file to notebooks when migrating through both deployment pipeline and DevOps, and to re-tag different environments in the notebook, you can follow these steps:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Ensure your ENV file is included in your repository. This file should contain the necessary environment variables. In your deployment pipeline, add a step to copy the ENV file to the appropriate location in your notebook's directory. This can be done using a script or a task in your pipeline configuration.&lt;/LI&gt;
&lt;LI&gt;To re-tag different environments in the notebook, you can use deployment rules to specify environment-specific configurations. For example, you can define different configurations for development, staging, and production environments. In your deployment pipeline, use environment variables or parameters to dynamically set the environment tags. This can be done by modifying the notebook's metadata or configuration files during the deployment process.&lt;/LI&gt;
&lt;LI&gt;In your deployment rules, specify the environment-specific configurations.&lt;/LI&gt;
&lt;LI&gt;In your DevOps pipeline configuration, add steps to handle the ENV file and set environment variables. This can be done using tasks or scripts in your pipeline YAML file.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;If this helps, please consider marking it &lt;STRONG&gt;'Accept as Solution&lt;/STRONG&gt;' so others with similar queries may find it more easily. If not, please share the details.&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 07:14:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4393662#M6901</guid>
      <dc:creator>v-hashadapu</dc:creator>
      <dc:date>2025-02-04T07:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: Environment File in Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4398395#M7010</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/811908" target="_blank"&gt;@FabricPupil&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;, Hope your issue is solved. If it is, please consider marking the answer 'Accept as solution', so others with similar issues may find it easily. If it isn't, please share the details.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Feb 2025 14:46:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4398395#M7010</guid>
      <dc:creator>v-hashadapu</dc:creator>
      <dc:date>2025-02-06T14:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Environment File in Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4402217#M7080</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/811908" target="_blank" rel="noopener"&gt;@FabricPupil&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;, Hope your issue is solved. If it is, please consider marking the answer 'Accept as solution', so others with similar issues may find it easily. If it isn't, please share the details.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 06:41:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4402217#M7080</guid>
      <dc:creator>v-hashadapu</dc:creator>
      <dc:date>2025-02-10T06:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Environment File in Notebook</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4611626#M7948</link>
      <description>&lt;P&gt;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/882992"&gt;@v-hashadapu&lt;/a&gt;&amp;nbsp; how are you getting getVariable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="smpa01_0-1742094497588.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1250780i549DD444FEF09E21/image-size/medium?v=v2&amp;amp;px=400" role="button" title="smpa01_0-1742094497588.png" alt="smpa01_0-1742094497588.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Mar 2025 03:08:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Environment-File-in-Notebook/m-p/4611626#M7948</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2025-03-16T03:08:43Z</dc:date>
    </item>
  </channel>
</rss>

