本文介绍了在虚拟机规模集中设置环境变量(Linux VM)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在尝试在所有比例集实例中设置环境变量。为此,我添加了custom_script_for_linux_extension。该脚本包含以下信息:


#!/ bin / bash



导出用户=测试

导出密码= test123

export secrettoken = 67890-9877ghkl


退出



脚本已成功部署,但我看不到环境变量。这些实例有linux vm(ubuntu)。


我甚至尝试了以下信息,但遗憾的是部署失败,说它无法访问.profile或.bashrc


#!/ bin / bash 

if [-z" $ user" ]
然后
echo"设置用户信息"
echo" export user = test">>〜/ .profile
echo" export password = test123">>〜/ .profile
echo" export secrettoken = 67890-9877ghkl">>〜/ .profile
echo" export user = test">>〜/ .bashrc
echo" export password = test123">>〜/ .bashrc
echo" export secrettoken = 67890-9877ghkl">>〜/ .bashrc
。 〜/ .bashrc
。 〜/ .profile

else
echo"用户信息已经存在"
fi
退出




我试图在我的java问题中获取环境变量。如何在azure vmss中设置环境变量,以便所有当前和自动调整的实例都有环境变量?


解决方案

Hello all,

I am trying to set environment variables in all scale-set instances. To do this, I added a custom_script_for_linux_extension. The script contained the following information:

#!/bin/bash

export user=test
export password=test123
export secrettoken=67890-9877ghkl

exit

The script deployed successfully but i could not see environment variables. The instances have linux vm (ubuntu).

I even tried the following information but unfortunately the deployment failed saying it cannot access .profile or .bashrc

#!/bin/bash

if [ -z "$user" ]
then
    echo "Setting user information"
    echo "export user=test">>~/.profile
    echo "export password=test123">>~/.profile
    echo "export secrettoken=67890-9877ghkl">>~/.profile
    echo "export user=test">>~/.bashrc
    echo "export password=test123">>~/.bashrc
    echo "export secrettoken=67890-9877ghkl">>~/.bashrc
    . ~/.bashrc
    . ~/.profile

else
      echo "user information is already present"
fi
exit


I am trying to get environment variables in my java problem. How do i set environment variables in azure vmss so that all the current and autoscaled instances have environment variables?

解决方案


这篇关于在虚拟机规模集中设置环境变量(Linux VM)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 13:05