在虚拟机规模集中设置环境变量(Linux VM) [英] Setting environment variable in virtual machine scale set (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?
I would suggest looking into using a Custom image instead of Custom Script Extension to set the variables.
This will allow any new instances that get added to your scale set to use that preconfigured image where all the environment variables will already be set.
这篇关于在虚拟机规模集中设置环境变量(Linux VM)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!