Secrets
Add API keys, passwords and connection strings that your app's Rayfin functions read on the server, without putting their values in your code.
Secrets are values such as API keys, passwords and connection strings that your app needs on the server but must never send to the browser. In the Secrets tab, you add them by name, and your app's Rayfin functions read them by name. Their values never go into your code or History.
Each secret has a value on this computer, which your app uses while it runs here, and once the app is published, a value on the published app.
Important
Only Rayfin functions can read secrets. Functions are available from Rayfin 1.36, but not in every Fabric region or tenant. See Functions in Rayfin's docs.


Before you start
- You can add secrets before you publish your app: a new secret's value goes to this computer.
- Use Rayfin 1.36 or newer. With an older version, the tab shows Update Rayfin to use secrets: select Rayfin in the status bar and choose Update with Copilot.
- In a team app, you add secrets and set their values on this computer the same way, but you change the values of the team's deployments in the Fabric portal. See Secrets in a team app.
Open the Secrets tab
- Open a project.
- In the app bar, select Code.
- In the code view's segmented control, select Secrets.
The tab lists each secret's name and description, and whether it has a value: under Local value, and under Published value, once the app is published. It never shows values: nobody can read a value back, not even you. With nothing selected, the side panel counts the secrets that have a value on this computer and on the published app.
Values on this computer and on the published app
Each secret can have two values:
- Local value: what your app's functions read while the app runs on this computer. It's saved in the project's
.rayfin-localfolder, outside your code and History. - Published value: what the published app's functions read. You can set it once the app is published.
The two are separate: setting one doesn't change the other. After you publish an app for the first time, give its secrets published values too.
A local value shows one of these:
| Local value | What it means |
|---|---|
| Set on this computer | You set a value here. |
| From your environment | Your app uses the environment variable of the same name that Fabricator started with. To change it, change the variable and restart Fabricator. |
| From local.settings.json | Your app uses the value in local.settings.json in the functions folder. A value you set here is used instead. |
| Not set | Functions that read the secret fail when your app runs on this computer. Set a value to fix that. |
A published value shows Set or Not set, and Couldn’t check when Fabricator can't read your published app's values.
Add a secret
- Select New secret.
- Type a Name. Fabricator writes names in capital letters with underscores, such as
OPENAI_API_KEY. A name starts with a letter. - Paste the Value. To check what you pasted, select Show value (the eye button).
- Optionally, fill in What it’s for. Never put the value here.
- Select Add secret.
Fabricator adds the name and description to rayfin/rayfin.yml, updates the types that functions use, and saves that change to git history as "Add secret: NAME". The value goes to this computer, as the secret's local value: Fabricator hands it straight to your app's local backend. For a published app, set its published value too.
Use a secret in a function
A function reads a secret by its name:
const apiKey = ctx.Secrets.OPENAI_API_KEYSelect a secret to see this line with a copy button. To have Copilot use the secret, select Ask Copilot to use it: Fabricator switches to Build and places a request about the secret in the chat composer, so you can add what the function should do before you send it. Copilot sees the secret's name, never its value.
Add a Rayfin function that summarizes an expense's notes with the OpenAI API, using the OPENAI_API_KEY secret. Show the summary on the expense details page, with a loading state while it runs.Read secrets only inside functions. Code that runs in the browser can't see secrets, and anything you put there is public. For how functions read secrets, see Secrets in functions in Rayfin's docs.
Copilot doesn't set secret values: when a function needs a new secret, it adds the name to rayfin/rayfin.yml and asks you to set the value here. It never asks for a value in chat.
Set or replace a value
To set the value on this computer:
- Select the secret.
- Under Local value, select Set, or Change when it has a value.
- Paste the value, then select Set value or Change value.
To set the value on the published app:
- Select the secret.
- Under Published value, select Set value, or Replace value when it has a value.
- Paste the value, then select Set value or Replace value.
Functions get the new value from their next run. Because nobody can read a value back, keep the original in a safe place, such as your password manager or the service that issued it.
Remove a local value
- Select the secret.
- Under Local value, select Remove, then confirm Remove.
Functions that read the secret fail when your app runs on this computer, until you set a value again. Remove appears for values you set here, not for values from your environment or local.settings.json.
Delete a secret
- Select the secret.
- Under Published value, select Delete, then confirm Delete.
Fabricator removes the secret from your published app and from rayfin/rayfin.yml. Functions that read it stop working until you add it again. Delete appears when the published app has a value for the secret.
Fix a secret that shows Not set
A secret's published value shows Not set when rayfin/rayfin.yml lists it but the published app has no value for it, for example after you publish the app to another Fabric workspace. Functions that read it fail in the published app.
- Select the secret.
- Under Published value, select Set value.
- Paste its value, then select Set value.
A local value that shows Not set works the same way: under Local value, select Set.
A secret shows Not in rayfin.yml when it has a value but rayfin/rayfin.yml doesn't list it, so functions can't read it by name. To add it, set its published value again. If you don't need it, remove its value.
Secrets in a team app
A team app runs on this computer while you work, and its functions read your local values, the same as any app's. The team's pipeline deploys it twice: the published app that everyone uses, and your preview, when you publish. Each deployment keeps its own secrets, so your preview's functions read your preview's secrets, and the published app's functions read the published app's secrets.
For a team app, the Secrets tab lists:
- On this computer: the app's secrets and their Local value. Add a secret, and set, change or remove its local value, the same way as for any app. Your local values stay on this computer: your teammates set their own.
- Published app and Your preview: the secrets of each deployment, which Fabricator can't change yet. Until your preview deploys, Your preview shows "Not deployed yet. Your preview deploys when you publish, and its secrets show here then." If a deploy fails, the tab still lists the secrets of the version that's live.
A secret you add is saved to your working copy on GitHub with your other changes, and the team gets its name when you publish. Its values on your preview and on the published app are set in the Fabric portal:
- In the Secrets tab, select Open in Fabric next to Published app or Your preview. The app opens in the Fabric portal.
- Add or change the secret there.
- In Fabricator, select Refresh at the top of the tab.
Ask Copilot to use it works the same as for other apps. When the secret shows Not in rayfin.yml, the request also asks Copilot to add it to rayfin/rayfin.yml, so functions can read it by name.
If the tab can't read your secrets
If the tab shows "Couldn’t read your published app’s secrets.", the message after it says why. When your Fabric sign-in has expired, it adds: "Your Fabric sign-in may have expired: open the account menu and select Refresh Fabric authentication, then try again." Do that, then select Try again.
If the tab says "Couldn’t check the values on this computer.", the message after it says why, and the local values show Couldn’t check. Fabricator reads them with the local backend that comes with it: if Windows blocked the local backend, see Windows blocked rayfin-local.
If it still fails, see Report a problem.
Skills
Choose the skills Copilot follows while it builds your Rayfin app, see what each one teaches, and add custom skills for your own guidance.
Publish to Microsoft Fabric
Publish your app to a Fabric workspace, choose whether chat turns publish it automatically, and manage the workspaces it's published to.