Why is that the env variable I set via GitHub Action for an Azure SWA not accessable in application

Sajith Aravindakshan 20 Reputation points
2024-03-27T10:32:54.6533333+00:00

I am trying to add an env variable for my SWA through GitHub Actions and here in the relavent section in my yml file

User's image

I am trying to access the same env variable in Azure Static WebApp Api application

System.Environment.GetEnvironmentVariable("TEST_SECRET")?.ToString();

The above value id always null.

What am i missing?

Here is the Microsoft documentation and I am following exactly the same.

Any pointers to what I am doing wrong is very much appreciated.

User's image

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,173 questions
0 comments No comments
{count} votes

Accepted answer
  1. TP 124.7K Reputation points Volunteer Moderator
    2024-03-27T11:05:28.1266667+00:00

    Hi Sajith,

    Environment variables in the yml file are for use during the build. They are not available for use when your application is running.

    https://docs.github.com/en/actions/learn-github-actions/variables

    Please click Accept Answer and upvote if the above was helpful.

    Thanks.

    -TP

    1 person found this answer helpful.

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.