Share via

Passing Application Insights environment variable (APPLICATIONINSIGHTS_SAMPLING_PERCENTAGE) at run time is not reflecting in the Azure portal?

Anonymous
2024-01-09T20:15:00+00:00

I would like to know if we can update environment variables dynamically. I've used below command to update the APPLICATIONINSIGHTS_SAMPLING_PERCENTAGE locally. It worked locally and pod name has the new environment variable but it is not reflecting in the Container environment variables and not updating the Sampling percentage to 50% as well. I would like to understand, is there a way to dynamically update environment variable? Please explain.

kubectl exec -it <PODNAME> -- bash -c 'export APPLICATIONINSIGHTS_SAMPLING_PERCENTAGE=50; echo $APPLICATIONINSIGHTS_SAMPLING_PERCENTAGE'

FYI:

can I set container environment varaible dynamically at runtime ?

In a typical containerized application, environment variables are often set during the container startup, and their values are fixed throughout the container's lifecycle. However, if you need to dynamically update environment variables at runtime within a running container, it becomes a more complex task and may not be the recommended approach due to various reasons, including security and immutability principles associated with containers.

Here's an example of how you might set environment variables dynamically at runtime within a container:

docker exec -it <container_id> bash -c 'export MY_VARIABLE=new_value && echo $MY_VARIABLE'

Explanation:

docker exec -it <container_id> : This command allows you to execute a command inside a running container interactively.

bash -c 'export MY_VARIABLE=new_value && echo $MY_VARIABLE' : This command is executed inside the container. It exports a new value for the MY_VARIABLE environment variable and then prints the variable.

Microsoft 365 and Office | Install, redeem, activate | For business | Other

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Anonymous
    2024-01-10T08:40:21+00:00

    Hi Rohini,

    Thanks for posting in the community.

    We would love to help you with your query, however, our team focuses on Microsoft 365 Apps product and Office queries. Since your query is related to Sampling in Application Insights, and we have a specific channel Microsoft Q&A Community coping with such questions, I recommend you post a new thread (assign the tag Azure Monitor) there for expert help.

    Sorry for that our category may have limited resources to check on the situation further. Appreciate your understanding and patience.

    Sincerely, 

    George | Microsoft Community Moderator

    Was this answer helpful?

    0 comments No comments