在azure vm模板中设置环境变量
嗨,我很好奇是否有人可以帮我设置在azure模板中向vm添加环境变量在azure vm模板中设置环境变量,azure,cloud,azure-vm-templates,Azure,Cloud,Azure Vm Templates,嗨,我很好奇是否有人可以帮我设置在azure模板中向vm添加环境变量 { "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "adminPassword": { "defaultValue": null,
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminPassword": {
"defaultValue": null,
"type": "SecureString"
},
"processtype": {
"type": "String",
"defaultValue": "sfm",
"allowedValues": [
"sfm",
"mvs",
"mesh",
"text",
"import",
"temp"
]
},
"vmSize": {
"type" : "String",
"defaultValue": "Standard_D12_v2",
"allowedValues": [
"Basic_A2",
"Standard_D12_v2",
"Standard_D13_v2",
"Standard_D14_v2"
]
},
"id": {
"type": "String",
"defaultValue": "0000",
"minLength": 4,
"maxLength": 4
}
},
"variables": {
"location":"northeurope",
"instance_name" : "[toUpper(concat('ps_', parameters('processtype'),'_',parameters('id')))]",
"unique_string": "[uniqueString(resourceGroup().id, variables('instance_name'))]",
"unique_name" : "[toUpper(variables('unique_string'))]",
"networkSecurityGroupName": "[toUpper(concat('nsg',variables('unique_name')))]",
"virtualNetworkName" : "[toUpper(concat('ns', variables('unique_name')))]",
"addressPrefix": "10.0.0.0/16",
"subnetName": "Subnet",
"subnetPrefix": "10.0.0.0/24",
"subnetRef": "[toUpper(concat(variables('vnetID'),'/subnets/',variables('subnetName')))]",
"vnetID":"[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
"publicIPAddressName": "[toUpper(concat('ip', variables('unique_name')))]",
"storageAccountName": "<storageAcName>",
"networkInterfaceName": "[toUpper(concat('ni', variables('unique_name')))]"
},
"resources": [
{
"comments": "Generalized VM",
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat(variables('instance_name'), '_' ,variables('unique_name'))]",
"apiVersion": "2015-06-15",
"location": "[variables('location')]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"storageProfile": {
"osDisk": {
"osType": "Windows",
"name": "[variables('unique_name')]",
"createOption": "FromImage",
"image":{
"uri": "<VHDPATH>"
},
"vhd": {
"uri": "[concat('<vhd path>',variables('unique_name'),'.vhd')]"
},
"caching": "ReadWrite"
},
"dataDisks": []
},
"osProfile": {
"computerName": "[parameters('processtype')]",
"adminUsername": "<username>",
"windowsConfiguration": {
"provisionVMAgent": true,
"enableAutomaticUpdates": true
},
"secrets": [],
"adminPassword": "[parameters('adminPassword')]"
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('networkInterfaceName'))]"
}
]
}
},
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"[resourceId('Microsoft.Network/networkInterfaces', variables('networkInterfaceName'))]"
]
},
{
"comments": "Generalized Security Group",
"type": "Microsoft.Network/networkSecurityGroups",
"name": "[variables('networkSecurityGroupName')]",
"apiVersion": "2016-03-30",
"location": "[variables('location')]",
"properties": {
"securityRules": [
{
"name": "default-allow-rdp",
"properties": {
"protocol": "*",
"sourcePortRange": "*",
"destinationPortRange": "3389",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 1000,
"direction": "Inbound"
}
}
]
},
"dependsOn": []
},
{
"comments": "Generalized IP Configuration",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[variables('publicIPAddressName')]",
"apiVersion": "2016-03-30",
"location": "[variables('location')]",
"properties": {
"publicIPAllocationMethod": "Dynamic",
"idleTimeoutInMinutes": 4
},
"dependsOn": []
},
{
"comments": "Generalized virtual network",
"type": "Microsoft.Network/virtualNetworks",
"name": "[variables('virtualNetworkName')]",
"apiVersion": "2016-03-30",
"location": "[variables('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [ "[variables('addressPrefix')]" ]
},
"subnets": [ {
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]"
}
} ]
},
"dependsOn": []
},
{
"comments": "Generalized Network Interface",
"type": "Microsoft.Network/networkInterfaces",
"name": "[variables('networkInterfaceName')]",
"apiVersion": "2016-03-30",
"location": "[variables('location')]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
},
"subnet": {
"id": "[concat(resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName')), '/subnets/', variables('subnetName'))]"
}
}
}
],
"dnsSettings": {
"dnsServers": []
},
"enableIPForwarding": false,
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
]
},
{
"comments": "Generalized storage account.",
"type": "Microsoft.Storage/storageAccounts",
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"kind": "Storage",
"name": "[variables('storageAccountName')]",
"apiVersion": "2016-01-01",
"location": "[variables('location')]",
"tags": {},
"properties": {},
"dependsOn": []
}
]
}
{
“$schema”:”https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
“内容版本”:“1.0.0.0”,
“参数”:{
“管理员密码”:{
“defaultValue”:空,
“类型”:“SecureString”
},
“进程类型”:{
“类型”:“字符串”,
“defaultValue”:“sfm”,
“允许值”:[
“sfm”,
“mvs”,
“网格”,
“文本”,
“进口”,
“临时工”
]
},
“vmSize”:{
“类型”:“字符串”,
“defaultValue”:“Standard_D12_v2”,
“允许值”:[
“基础课程A2”,
“标准D12\u v2”,
“标准D13\U v2”,
“标准_D14_v2”
]
},
“id”:{
“类型”:“字符串”,
“defaultValue”:“0000”,
“最小长度”:4,
“最大长度”:4
}
},
“变量”:{
“地点”:“北欧”,
“实例名称”:“[toUpper(concat('ps_u',parameters('processtype'),'u',parameters('id'))]”,
“唯一字符串”:“[uniqueString(resourceGroup().id,变量('instance_name'))]”,
“唯一名称”:“[toUpper(变量('unique_字符串'))]”,
“networkSecurityGroupName”:“[toUpper(concat('nsg',variables('unique_name'))]”,
“virtualNetworkName”:“[toUpper(concat('ns',variables('unique_name'))]”,
“地址前缀”:“10.0.0.0/16”,
“子网名称”:“子网”,
“子网前缀”:“10.0.0.0/24”,
“subnetRef”:“[toUpper(concat(variables('vnetID'),'/subnets/',variables('subnetName')))]”,
“vnetID”:“[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]”,
“publicIPAddressName”:“[toUpper(concat('ip',variables('unique_name'))]”,
“storageAccountName”:“”,
“networkInterfaceName”:“[toUpper(concat('ni',variables('unique_name'))]”
},
“资源”:[
{
“注释”:“通用虚拟机”,
“类型”:“Microsoft.Compute/VirtualMachine”,
“名称”:“[concat(variables('instance_name'),''u',variables('unique_name'))]”,
“apiVersion”:“2015-06-15”,
“位置”:“[变量('位置')]”,
“财产”:{
“硬件配置文件”:{
“vmSize”:“[参数('vmSize')”
},
“存储配置文件”:{
“osDisk”:{
“osType”:“Windows”,
“名称”:“[变量('unique_name')]”,
“createOption”:“FromImage”,
“图像”:{
“uri”:”
},
“vhd”:{
“uri”:“[concat(“”,variables('unique_name'),'.vhd')”
},
“缓存”:“读写”
},
“数据磁盘”:[]
},
“osProfile”:{
“computerName”:“[参数('processtype')]”,
“adminUsername”:“,
“Windows配置”:{
“provisionVMAgent”:true,
“EnableAutomaticCupDates”:正确
},
“秘密”:[],
“adminPassword”:“[参数('adminPassword')”
},
“网络配置文件”:{
“网络接口”:[
{
“id”:“[resourceId('Microsoft.Network/networkInterfaces',variables('networkInterfaceName'))”
}
]
}
},
“dependsOn”:[
“[resourceId('Microsoft.Storage/storageAccounts',variables('storageAccountName'))]”,
[resourceId('Microsoft.Network/networkInterfaces',variables('networkInterfaceName'))]
]
},
{
“评论”:“通用安全组”,
“类型”:“Microsoft.Network/networkSecurityGroups”,
“名称”:“[变量('networkSecurityGroupName')]”,
“apiVersion”:“2016-03-30”,
“位置”:“[变量('位置')]”,
“财产”:{
“安全规则”:[
{
“名称”:“默认允许rdp”,
“财产”:{
“协议”:“*”,
“sourcePortRange”:“*”,
“destinationPortRange”:“3389”,
“sourceAddressPrefix”:“*”,
“destinationAddressPrefix”:“*”,
“访问”:“允许”,
“优先”:1000,
“方向”:“入站”
}
}
]
},
“dependsOn”:[]
},
{
“注释”:“通用IP配置”,
“类型”:“Microsoft.Network/PublicIP地址”,
“名称”:“[变量('publicIPAddressName')]”,
“apiVersion”:“2016-03-30”,
“位置”:“[变量('位置')]”,
“财产”:{
“publicIPAllocationMethod”:“动态”,
“IdleTimeOutingMinutes”:4
},
“dependsOn”:[]
},
{
“评论”:“广义虚拟网络”,
“类型”:“Microsoft.Network/virtualNetworks”,
“名称”:“[变量('virtualNetworkName')]”,
“apiVersion”:“2016-03-30”,
“位置”:“[变量('位置')]”,
“财产”:{
“地址空间”:{
“地址前缀”:[“[变量('addressPrefix')]”
},
“子网”:[{
“名称”:“[变量('s