嗨,我很好奇是否有人可以帮助我设置将环境变量添加到 azure 模板中的 vm。
{
"$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": []
}
]
}
以上是我目前的模板。在哪里可以指定环境变量或其他可在 vm 中访问的变量?