In Azure ML we have created compute instance by using setup shell script and we also installed custom RStudio open-source application using below MS docs
Create and manage a compute instance - Azure Machine Learning | Microsoft Learn
In setup shell script we define environment variable
In terminal we are able to read above variable
azureuser@test-whdh:~/cloudfiles/code/Users/ashaikh$ R
R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
Sys.getenv("AZURE_CLIENT_ID")
[1] "5422axxxxxxxxxxxxxxxxx"
However, we are not able to read above variable in custom RStudio open-source application.