Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowHi All,
How do we attached ENV file to the notebooks when migrating through both deployment pipeline and devops.
Hi @FabricPupil , 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.
Thank you.
Hi @FabricPupil , 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.
Thank you.
Hi @FabricPupil , 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.
Thank you.
Hi @FabricPupil , thank you for reaching out to the Microsoft Fabric Community Forum.
Microsoft Fabric does not natively support attaching .env files to notebooks. However, you can manage environment variables in different ways:
from notebookutils import mssparkutils
# Get an environment variable
value = mssparkutils.env.getVariable("MY_ENV_VAR")
print(value)
import os
# Read .env file from Lakehouse Files
file_path = "/lakehouse/default/Files/config/.env"
with open(file_path, "r") as f:
for line in f:
key, value = line.strip().split("=")
os.environ[key] = value
# Access an environment variable
print(os.getenv("MY_CUSTOM_VAR"))
from notebookutils import mssparkutils
# Get a secret from Azure Key Vault
secret_value = mssparkutils.credentials.getSecret("my-key-vault", "MY_SECRET_KEY")
print(secret_value)
If this helps, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details.
Thank you.
Hi @FabricPupil
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:
Use NotebookUtils: Fabric provides NotebookUtils for working with environment variables. You can use the following code to access environment variables:
from notebookutils import mssparkutils
# Get an environment variable
value = mssparkutils.env.getVariable("VARIABLE_NAME")
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.
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.
please accept this solution and give kudos if this is helpful.
thanks
Nilendra
Hi,
I am looking to call fabric env files which has built in libraries and allows public/custom libraries.
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)
Hi @FabricPupil , thank you for reaching out to the Microsoft Fabric Community Forum.
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:
If this helps, please consider marking it 'Accept as Solution' so others with similar queries may find it more easily. If not, please share the details.
Thank you.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
User | Count |
---|---|
35 | |
6 | |
2 | |
2 | |
1 |
User | Count |
---|---|
49 | |
9 | |
7 | |
6 | |
5 |