This commit is contained in:
Rakesh Kumar 2021-10-11 11:31:31 -07:00
Родитель 058949bc1a
Коммит 9a5fff4670
11 изменённых файлов: 43 добавлений и 1572 удалений

Просмотреть файл

@ -1,10 +1,19 @@
# Multiple VM Availability Set
Deploys a set of Linix VM´s (centos ) as part of the same availability set. This template template also deploys an availability set, a virtual Network (with DNS), a load balancer with a front end Public IP address, and a Network Security Group.
VM´s require the following Deployed Centos Images:
*osImagePublisher: Centos*
*osImageOffer: Centos-7*
*osImageSKU: Centos-7.4*
Deploys a set of Linux VM´s (centos ) as part of the same availability set. This template template also deploys an availability set, a virtual Network (with DNS), a load balancer with a front end Public IP address, and a Network Security Group.
VM´s require the following Deployed Centos or Ubuntu Image:
*osImagePublisher: Centos, Canonical
*osImageOffer: Centos-7, UbuntuServer
*osImageSKU: Centos-7.4, 16.04-LTS
# Deploy using Az CLI
```Powershell
# update parameters values in azuredeploy.parametrs.json file and run below commands
# create resource group if it doesn't exist
az group create --name testrg --location "local"
# ARM template deployment
az deployment group create --resource-group testrg --template-file .\azuredeploy.json --parameters .\azuredeploy.parameters.json
# Bicep deployment
az deployment group create --resource-group testrg --template-file .\azuredeploy.bicep --parameters .\azuredeploy.parameters.json
```

Просмотреть файл

@ -1,381 +0,0 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.4.613.9944",
"templateHash": "12142450251540046373"
}
},
"parameters": {
"adminUsername": {
"type": "string",
"defaultValue": "vmadmin",
"metadata": {
"description": "The name of the Administrator of the new VMs"
}
},
"adminPassword": {
"type": "secureString",
"defaultValue": "[format('Subscription#{0}', substring(resourceGroup().id, 15, 36))]",
"metadata": {
"description": "The password for the Administrator account of the new VMs. Default value is subscription id"
}
},
"numberOfInstances": {
"type": "int",
"defaultValue": 3,
"allowedValues": [
2,
3,
4,
5
],
"metadata": {
"description": "Number of VMs to deploy, limit 5 since this sample is using a single storage account"
}
},
"dataDiskSize": {
"type": "int",
"defaultValue": 1000,
"allowedValues": [
100,
500,
750,
1000
],
"metadata": {
"description": "Size of the Data Disk"
}
},
"vmNamePrefix": {
"type": "string",
"defaultValue": "vmset-",
"metadata": {
"description": "VM name prefix"
}
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_A1",
"allowedValues": [
"Standard_A1",
"Standard_A2",
"Standard_A3",
"Standard_A4",
"Standard_D1",
"Standard_D2",
"Standard_D3",
"Standard_D4"
],
"metadata": {
"description": "This is the size of your VM"
}
},
"dnsPrefix": {
"type": "string",
"defaultValue": "vmdns",
"metadata": {
"description": "dns name prefix"
}
},
"osImagePublisher": {
"type": "string",
"defaultValue": "Canonical",
"metadata": {
"description": "Maps to the publisher in the Azure Stack Platform Image Repository manifest file."
}
},
"osImageOffer": {
"type": "string",
"defaultValue": "UbuntuServer",
"metadata": {
"description": "Maps to the Offer in the Azure Stack Platform Image Repository manifest file."
}
},
"osImageSKU": {
"type": "string",
"defaultValue": "16.04-LTS",
"allowedValues": [
"Centos-7.4",
"16.04-LTS"
],
"metadata": {
"description": "The Linux version for the VM. This will pick a fully patched image of this given Centos"
}
}
},
"functions": [],
"variables": {
"availabilitySetName": "[toLower(format('aSet-{0}', resourceGroup().name))]",
"storageAccountType": "Standard_LRS",
"osImageVersion": "latest",
"addressPrefix": "10.0.0.0/16",
"virtualNetworkName": "[toLower(format('vNet-{0}', resourceGroup().name))]",
"NICPrefix": "vnic-",
"subnetPrefix": "10.0.0.0/24",
"subnetName": "vmstaticsubnet",
"storageName": "[format('sa{0}', uniqueString(resourceGroup().id))]",
"publicLBName": "[toLower(format('external-lb-{0}', resourceGroup().name))]",
"lbFE": "[toLower(format('external-lb-fe-{0}', resourceGroup().name))]",
"publicIPAddressName": "[toLower(format('public-ip{0}', resourceGroup().name))]",
"nsgName": "[toLower(format('vmnsg{0}', resourceGroup().name))]",
"vmContainerName": "vhds"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[variables('storageName')]",
"location": "[resourceGroup().location]",
"sku": {
"name": "[variables('storageAccountType')]"
},
"kind": "Storage",
"dependsOn": [
"[resourceId('Microsoft.Network/loadBalancers', variables('publicLBName'))]"
]
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2018-11-01",
"name": "[variables('nsgName')]",
"location": "[resourceGroup().location]",
"properties": {
"securityRules": [
{
"name": "rule1",
"properties": {
"protocol": "*",
"sourcePortRange": "*",
"destinationPortRange": "*",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 101,
"direction": "Inbound"
}
}
]
}
},
{
"type": "Microsoft.Compute/availabilitySets",
"apiVersion": "2020-06-01",
"name": "[variables('availabilitySetName')]",
"location": "[resourceGroup().location]",
"properties": {
"platformFaultDomainCount": 1,
"platformUpdateDomainCount": 1
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2018-11-01",
"name": "[variables('publicIPAddressName')]",
"location": "[resourceGroup().location]",
"properties": {
"publicIPAllocationMethod": "Dynamic",
"dnsSettings": {
"domainNameLabel": "[parameters('dnsPrefix')]"
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
]
},
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2018-11-01",
"name": "[variables('virtualNetworkName')]",
"location": "[resourceGroup().location]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]",
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]"
}
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('nsgName'))]"
]
},
{
"type": "Microsoft.Network/loadBalancers",
"apiVersion": "2018-11-01",
"name": "[variables('publicLBName')]",
"location": "[resourceGroup().location]",
"properties": {
"frontendIPConfigurations": [
{
"name": "[variables('lbFE')]",
"properties": {
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
}
}
}
],
"backendAddressPools": [
{
"name": "LoadBalancerBackend"
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
]
},
{
"copy": {
"name": "inboundNatRule",
"count": "[length(range(0, parameters('numberOfInstances')))]"
},
"type": "Microsoft.Network/loadBalancers/inboundNatRules",
"apiVersion": "2018-11-01",
"name": "[format('{0}/ssh-VM{1}', variables('publicLBName'), range(0, parameters('numberOfInstances'))[copyIndex()])]",
"properties": {
"frontendIPConfiguration": {
"id": "[reference(resourceId('Microsoft.Network/loadBalancers', variables('publicLBName'))).frontendIPConfigurations[0].id]"
},
"protocol": "Tcp",
"frontendPort": "[add(range(0, parameters('numberOfInstances'))[copyIndex()], 2200)]",
"backendPort": 22,
"enableFloatingIP": false
},
"dependsOn": [
"[resourceId('Microsoft.Network/loadBalancers', variables('publicLBName'))]"
]
},
{
"copy": {
"name": "networkInterface",
"count": "[length(range(0, parameters('numberOfInstances')))]"
},
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2018-11-01",
"name": "[format('{0}{1}{2}', variables('NICPrefix'), parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]",
"location": "[resourceGroup().location]",
"properties": {
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[reference(resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))).subnets[0].id]"
},
"loadBalancerBackendAddressPools": [
{
"id": "[reference(resourceId('Microsoft.Network/loadBalancers', variables('publicLBName'))).backendAddressPools[0].id]"
}
],
"loadBalancerInboundNatRules": [
{
"id": "[resourceId('Microsoft.Network/loadBalancers/inboundNatRules', split(format('{0}/ssh-VM{1}', variables('publicLBName'), range(0, parameters('numberOfInstances'))[range(0, parameters('numberOfInstances'))[copyIndex()]]), '/')[0], split(format('{0}/ssh-VM{1}', variables('publicLBName'), range(0, parameters('numberOfInstances'))[range(0, parameters('numberOfInstances'))[copyIndex()]]), '/')[1])]"
}
]
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/loadBalancers/inboundNatRules', split(format('{0}/ssh-VM{1}', variables('publicLBName'), range(0, parameters('numberOfInstances'))[range(0, parameters('numberOfInstances'))[copyIndex()]]), '/')[0], split(format('{0}/ssh-VM{1}', variables('publicLBName'), range(0, parameters('numberOfInstances'))[range(0, parameters('numberOfInstances'))[copyIndex()]]), '/')[1])]",
"[resourceId('Microsoft.Network/loadBalancers', variables('publicLBName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
]
},
{
"copy": {
"name": "virtualMachine",
"count": "[length(range(0, parameters('numberOfInstances')))]"
},
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2020-06-01",
"name": "[format('{0}{1}', parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]",
"location": "[resourceGroup().location]",
"properties": {
"availabilitySet": {
"id": "[resourceId('Microsoft.Compute/availabilitySets', variables('availabilitySetName'))]"
},
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[format('{0}{1}', parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[parameters('osImagePublisher')]",
"offer": "[parameters('osImageOffer')]",
"sku": "[parameters('osImageSKU')]",
"version": "[variables('osImageVersion')]"
},
"osDisk": {
"name": "osdisk",
"vhd": {
"uri": "[format('{0}{1}/{2}{3}-osdisk.vhd', reference(format('Microsoft.Storage/storageAccounts/{0}', variables('storageName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob, variables('vmContainerName'), parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]"
},
"caching": "ReadWrite",
"createOption": "FromImage"
},
"dataDisks": [
{
"vhd": {
"uri": "[format('{0}{1}/{2}{3}-data-1.vhd', reference(format('Microsoft.Storage/storageAccounts/{0}', variables('storageName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob, variables('vmContainerName'), parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]"
},
"name": "[format('{0}{1}-data-disk1', parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]",
"createOption": "Empty",
"caching": "None",
"diskSizeGB": "[parameters('dataDiskSize')]",
"lun": 0
},
{
"vhd": {
"uri": "[format('{0}{1}/{2}{3}-data-2.vhd', reference(format('Microsoft.Storage/storageAccounts/{0}', variables('storageName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob, variables('vmContainerName'), parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]"
},
"name": "[format('{0}{1}-data-disk2', parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[copyIndex()])]",
"createOption": "Empty",
"caching": "None",
"diskSizeGB": "[parameters('dataDiskSize')]",
"lun": 1
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', format('{0}{1}{2}', variables('NICPrefix'), parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[range(0, parameters('numberOfInstances'))[copyIndex()]]))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[concat(reference(format('Microsoft.Storage/storageAccounts/{0}', variables('storageName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob)]"
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Compute/availabilitySets', variables('availabilitySetName'))]",
"[resourceId('Microsoft.Network/networkInterfaces', format('{0}{1}{2}', variables('NICPrefix'), parameters('vmNamePrefix'), range(0, parameters('numberOfInstances'))[range(0, parameters('numberOfInstances'))[copyIndex()]]))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageName'))]"
]
}
]
}

Просмотреть файл

@ -1,64 +1,11 @@
# [IaaS Linux VM using managed disk from custom image]
<a href="https://portal.local.azurestack.external/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazurestack-quickstart-templates%2Fmaster%2F101-simple-linux-vm-custom-managed-disk%2Fazuredeploy.json" target="_blank">
<img src="images/deploytoasdk.png"/>
</a>
<a href="http://armviz.io/#/?load=https://raw.githubusercontent.com/Azure/azurestack-quickstart-templates/master/101-simple-linux-vm-custom-managed-disk/azuredeploy.json" target="_blank">
<img src="http://armviz.io/visualizebutton.png"/>
</a>
# IaaS Linux VM using managed disk from custom image
This template deploys a Linux VM from a Custom Image using Managed Disk
![ManagedDisks](images/image.png)
`Tags: [Linux]`
| Endpoint | Version | Validated |
| ------------- |:-------------:| -----:|
| Microsoft Azure Stack | - | yes|
## Prerequisites
AzureStack must be 1901 or greater to support Custom Images
# Prerequisites
Prepare or Download a Customized Linux Image Template
Follow the below links to create/download a Linux Image
1. https://azure.microsoft.com/en-us/documentation/articles/azure-stack-linux/
2. https://azure.microsoft.com/en-us/documentation/articles/azure-stack-add-image-pir/
## Deployment Options
for all deployments, a vhd file and a ssh public key is required.
the powershell script option reads the key from a specified sshKeyfile ( your_keyfile.pub)
![ResourceGroup](images/rg.png)
1. Deploy to Azure Stack portal using custom deployment
Upload the Image to a Storage Account, with Public read Access
During Deployment, Specify the imageUri Parameter of the vhd
Deploy the Image using the Quickstart templates from Template Deployment
![template](images/template.png)
2. Deploy through Visual Studio
Upload the Image to a Storage Account, with Public read Access
During Deployment, Specify the imageUri Parameter of the vhd
use the azuredeploy.json and azuredeploy.parameters.json to deploy
3. Deploy the solution from PowerShell with the following PowerShell script
Follow the below link to configure the Azure Stack environment with Add-AzureRmEnvironment cmdlet and authenticate a user to the environment
https://docs.microsoft.com/en-us/azure/azure-stack/azure-stack-powershell-configure
the [ExampleScript](deploy_image.ps1) will create
- a Storage Account and Image Resource Group ( Default: image in image_rg)
- upload the Linux Image
- Deploy the vhd to Deployment resource Group
```Powershell
.\deploy_image.ps1 -sshKeyFile $HOME/key.pub -Image $HOME\Downloads\MyLinuxVM.vhd
```
4. Deploy using Az CLI
# Deploy using Az CLI
```Powershell
# update parameters values in azuredeploy.parametrs.json file and run below commands
# create resource group if it doesn't exist

Просмотреть файл

@ -1,238 +0,0 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.4.613.9944",
"templateHash": "17848823021747493143"
}
},
"parameters": {
"vmName": {
"type": "string",
"metadata": {
"description": "Name of the VM"
}
},
"adminUsername": {
"type": "string",
"defaultValue": "ubuntu",
"metadata": {
"description": "Username for the Virtual Machine. Default value is localadmin"
}
},
"sshkeyData": {
"type": "secureString",
"metadata": {
"description": "ssh key for vm"
}
},
"imageName": {
"type": "string",
"defaultValue": "myimage",
"metadata": {
"description": "Maps to the Image Name"
}
},
"imageUri": {
"type": "string",
"defaultValue": "",
"metadata": {
"description": "uri of the Image "
}
},
"vmSize": {
"type": "string",
"defaultValue": "Standard_A1",
"metadata": {
"description": "The size of the Virtual Machine."
}
}
},
"functions": [],
"variables": {
"publicIPName": "[format('PublicIP_{0}', parameters('vmName'))]",
"location": "[resourceGroup().location]",
"nicName": "[toLower(format('nic{0}', uniqueString(resourceGroup().id)))]",
"addressPrefix": "10.0.0.0/24",
"subnetName": "[toLower(format('subnet{0}', uniqueString(resourceGroup().id)))]",
"subnetPrefix": "10.0.0.0/24",
"diagnosticsStorageAccountName": "[toLower(format('diag{0}', uniqueString(resourceGroup().id)))]",
"virtualNetworkName": "[toLower(format('vnet{0}', uniqueString(resourceGroup().id)))]",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
"subnetRef": "[format('{0}/subnets/{1}', variables('vnetID'), variables('subnetName'))]",
"networkSecurityGroupName": "[toLower(format('nsg{0}', uniqueString(resourceGroup().id)))]",
"sshKeyPath": "[format('/home/{0}/.ssh/authorized_keys', parameters('adminUsername'))]"
},
"resources": [
{
"type": "Microsoft.Compute/images",
"apiVersion": "2017-03-30",
"name": "[parameters('imageName')]",
"location": "[variables('location')]",
"tags": {
"provisioner": "Image_Deploy"
},
"properties": {
"storageProfile": {
"osDisk": {
"osType": "Linux",
"osState": "Generalized",
"blobUri": "[parameters('imageUri')]",
"storageAccountType": "Standard_LRS",
"caching": "ReadWrite",
"diskSizeGB": 127
}
}
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2017-10-01",
"name": "[variables('diagnosticsStorageAccountName')]",
"location": "[variables('location')]",
"properties": {},
"sku": {
"name": "Standard_LRS"
},
"kind": "Storage"
},
{
"type": "Microsoft.Network/networkSecurityGroups",
"apiVersion": "2017-10-01",
"name": "[variables('networkSecurityGroupName')]",
"location": "[resourceGroup().location]",
"properties": {
"securityRules": [
{
"name": "ssh",
"properties": {
"description": "Allow ssh",
"protocol": "Tcp",
"sourcePortRange": "*",
"destinationPortRange": "22",
"sourceAddressPrefix": "*",
"destinationAddressPrefix": "*",
"access": "Allow",
"priority": 200,
"direction": "Inbound"
}
}
]
}
},
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2017-10-01",
"name": "[variables('virtualNetworkName')]",
"location": "[variables('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"[variables('addressPrefix')]"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "[variables('subnetPrefix')]"
}
}
]
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2017-10-01",
"name": "[variables('publicIPName')]",
"location": "[variables('location')]",
"tags": {
"provisioner": "image_deploy"
},
"properties": {
"publicIPAllocationMethod": "Static"
}
},
{
"type": "Microsoft.Network/networkInterfaces",
"apiVersion": "2017-10-01",
"name": "[variables('nicName')]",
"location": "[variables('location')]",
"properties": {
"networkSecurityGroup": {
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]"
},
"ipConfigurations": [
{
"name": "ipconfig1",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[variables('subnetRef')]"
},
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPName'))]"
}
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]",
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]"
]
},
{
"type": "Microsoft.Compute/virtualMachines",
"apiVersion": "2017-03-30",
"name": "[parameters('vmName')]",
"location": "[variables('location')]",
"properties": {
"hardwareProfile": {
"vmSize": "[parameters('vmSize')]"
},
"osProfile": {
"computerName": "[parameters('vmName')]",
"adminUsername": "[parameters('adminUsername')]",
"linuxConfiguration": {
"disablePasswordAuthentication": true,
"ssh": {
"publicKeys": [
{
"path": "[variables('sshKeyPath')]",
"keyData": "[parameters('sshkeyData')]"
}
]
}
}
},
"storageProfile": {
"imageReference": {
"id": "[resourceId('Microsoft.Compute/images', parameters('imageName'))]"
}
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "[reference(resourceId('Microsoft.Storage/storageAccounts', variables('diagnosticsStorageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob]"
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', variables('diagnosticsStorageAccountName'))]",
"[resourceId('Microsoft.Compute/images', parameters('imageName'))]",
"[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]"
]
}
]
}

Просмотреть файл

@ -2,14 +2,12 @@
This template allows you to deploy a VM Scale Set of Windows VMs. It uses the latest patched version of several Windows versions. To connect from the load balancer to a VM in the scale set, you would go to the AzureStack Portal, find the load balancer of your scale set, examine the NAT rules, then connect using the NAT rule you want. For example, if there is a NAT rule on port 50000, you could RDP on port 50000 of the public IP to connect to that VM. Similarly if something is listening on port 80 we can connect to it using port 80.
PARAMETER RESTRICTIONS
======================
# Parameter Restriction
vmssName must be 3-10 characters in length. It should also be globally unique across all of AzureStack. If it isn't globally unique, it is possible that this template will still deploy properly, but we don't recommend relying on this pseudo-probabilistic behavior.
InstanceCount must be 20 or less. VM Scale Set supports upto 100 VMs and one should add more storage accounts to support this number.
Deploy using Az CLI
# Deploy using Az CLI
```Powershell
# update parameters values in azuredeploy.parametrs.json file and run below commands
# create resource group if it doesn't exist

Просмотреть файл

@ -1,266 +0,0 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.4.613.9944",
"templateHash": "2475321128335912843"
}
},
"parameters": {
"vmSku": {
"type": "string",
"defaultValue": "Standard_A1",
"metadata": {
"description": "Size of VMs in the VM Scale Set."
}
},
"vmssName": {
"type": "string",
"defaultValue": "[substring(format('vmss{0}', uniqueString(replace(resourceGroup().id, '-', ''))), 0, 8)]",
"metadata": {
"description": "String used as a base for naming resources. Must be 3-10 characters in length and globally unique across Azure Stack. A hash is prepended to this string for some resources, and resource-specific information is appended."
}
},
"instanceCount": {
"type": "int",
"defaultValue": 2,
"maxValue": 20,
"metadata": {
"description": "Number of VM instances (20 or less)."
}
},
"adminUsername": {
"type": "string",
"defaultValue": "azureuser",
"metadata": {
"description": "Admin username on all VMs."
}
},
"adminPassword": {
"type": "secureString",
"defaultValue": "[format('Subscription#{0}', subscription().subscriptionId)]",
"metadata": {
"description": "Admin password on all VMs."
}
},
"osImagePublisher": {
"type": "string",
"defaultValue": "MicrosoftWindowsServer",
"metadata": {
"description": "Maps to the publisher in the Azure Stack Platform Image Repository manifest file."
}
},
"osImageOffer": {
"type": "string",
"defaultValue": "WindowsServer",
"metadata": {
"description": "Maps to the Offer in the Azure Stack Platform Image Repository manifest file."
}
},
"osImageSku": {
"type": "string",
"defaultValue": "2016-Datacenter",
"allowedValues": [
"2012-R2-Datacenter",
"2016-Datacenter-Server-Core",
"2016-Datacenter"
],
"metadata": {
"description": "The Windows version for the VM. This will pick a fully patched image of this given Windows version. Allowed values: 2008-R2-SP1, 2012-Datacenter, 2012-R2-Datacenter."
}
}
},
"functions": [],
"variables": {
"location": "[resourceGroup().location]",
"vnetName": "[toLower(format('vnet{0}', uniqueString(resourceGroup().id)))]",
"subnetName": "[toLower(format('subnet{0}', uniqueString(resourceGroup().id)))]",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]",
"subnetRef": "[format('{0}/subnets/{1}', variables('vnetID'), variables('subnetName'))]",
"publicIPAddressName": "[toLower(format('pip{0}', uniqueString(resourceGroup().id)))]",
"vmssDomainName": "[toLower(format('pubdns{0}', uniqueString(resourceGroup().id)))]",
"loadBalancerName": "[format('LB{0}', uniqueString(resourceGroup().id))]",
"loadBalancerFrontEndName": "[format('LBFrontEnd{0}', uniqueString(resourceGroup().id))]",
"loadBalancerBackEndName": "[format('LBBackEnd{0}', uniqueString(resourceGroup().id))]",
"loadBalancerProbeName": "[format('LBHttpProbe{0}', uniqueString(resourceGroup().id))]",
"loadBalancerNatPoolName": "[format('LBNatPool{0}', uniqueString(resourceGroup().id))]"
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2018-11-01",
"name": "[variables('vnetName')]",
"location": "[variables('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "10.0.0.0/24"
}
}
]
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2018-11-01",
"name": "[variables('publicIPAddressName')]",
"location": "[variables('location')]",
"properties": {
"publicIPAllocationMethod": "Dynamic",
"dnsSettings": {
"domainNameLabel": "[variables('vmssDomainName')]"
}
}
},
{
"type": "Microsoft.Network/loadBalancers",
"apiVersion": "2018-11-01",
"name": "[variables('loadBalancerName')]",
"location": "[variables('location')]",
"properties": {
"frontendIPConfigurations": [
{
"name": "[variables('loadBalancerFrontEndName')]",
"properties": {
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
}
}
}
],
"backendAddressPools": [
{
"name": "[variables('loadBalancerBackEndName')]"
}
],
"loadBalancingRules": [
{
"name": "roundRobinLBRule",
"properties": {
"frontendIPConfiguration": {
"id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('loadBalancerName'), variables('loadBalancerFrontEndName'))]"
},
"backendAddressPool": {
"id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('loadBalancerName'), variables('loadBalancerBackEndName'))]"
},
"protocol": "Tcp",
"frontendPort": 80,
"backendPort": 80,
"enableFloatingIP": false,
"idleTimeoutInMinutes": 5,
"probe": {
"id": "[resourceId('Microsoft.Network/loadBalancers/probes', variables('loadBalancerName'), variables('loadBalancerProbeName'))]"
}
}
}
],
"probes": [
{
"name": "[variables('loadBalancerProbeName')]",
"properties": {
"protocol": "Tcp",
"port": 80,
"intervalInSeconds": 5,
"numberOfProbes": 2
}
}
],
"inboundNatPools": [
{
"name": "[variables('loadBalancerNatPoolName')]",
"properties": {
"frontendIPConfiguration": {
"id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('loadBalancerName'), variables('loadBalancerFrontEndName'))]"
},
"protocol": "Tcp",
"frontendPortRangeStart": 50000,
"frontendPortRangeEnd": 50019,
"backendPort": 3389
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
]
},
{
"type": "Microsoft.Compute/virtualMachineScaleSets",
"apiVersion": "2020-06-01",
"name": "[parameters('vmssName')]",
"sku": {
"name": "[parameters('vmSku')]",
"tier": "Standard",
"capacity": "[parameters('instanceCount')]"
},
"location": "[variables('location')]",
"properties": {
"upgradePolicy": {
"mode": "Manual"
},
"virtualMachineProfile": {
"storageProfile": {
"osDisk": {
"caching": "ReadOnly",
"createOption": "FromImage"
},
"imageReference": {
"publisher": "[parameters('osImagePublisher')]",
"offer": "[parameters('osImageOffer')]",
"sku": "[parameters('osImageSku')]",
"version": "latest"
}
},
"osProfile": {
"computerNamePrefix": "[parameters('vmssName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "nic",
"properties": {
"primary": true,
"ipConfigurations": [
{
"name": "ipconfig",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
},
"loadBalancerBackendAddressPools": [
{
"id": "[reference(resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))).backendAddressPools[0].id]"
}
],
"loadBalancerInboundNatPools": [
{
"id": "[reference(resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))).inboundNatPools[0].id]"
}
]
}
}
]
}
}
]
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]"
]
}
]
}

Просмотреть файл

@ -2,14 +2,12 @@
This template allows you to deploy a VM Scale Set of Linux VMs with a custom script run on each VM. To connect from the load balancer to a VM in the scale set, you would go to the AzureStack Portal, find the load balancer of your scale set, examine the NAT rules, then connect using the NAT rule you want. For example, if there is a NAT rule on port 50000, you could RDP on port 50000 of the public IP to connect to that VM. Similarly if something is listening on port 80 we can connect to it using port 80.
PARAMETER RESTRICTIONS
======================
# Parameter Restriction
vmssName must be 3-10 characters in length. It should also be globally unique across all of AzureStack. If it isn't globally unique, it is possible that this template will still deploy properly, but we don't recommend relying on this pseudo-probabilistic behavior.
instanceCount must be 20 or less. VM Scale Set supports upto 100 VMs and one should add more storage accounts to support this number.
Deploy using Az CLI
# Deploy using Az CLI
```Powershell
# update parameters values in azuredeploy.parametrs.json file and run below commands
# create resource group if it doesn't exist

Просмотреть файл

@ -1,298 +0,0 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.4.613.9944",
"templateHash": "13430676828626038130"
}
},
"parameters": {
"vmSku": {
"type": "string",
"defaultValue": "Standard_D1",
"metadata": {
"description": "Size of VMs in the VM Scale Set."
}
},
"vmssName": {
"type": "string",
"defaultValue": "[substring(format('vmss{0}', uniqueString(replace(resourceGroup().id, '-', ''))), 0, 8)]",
"metadata": {
"description": "String used as a base for naming resources. Must be 3-10 characters in length and globally unique across Azure Stack. A hash is prepended to this string for some resources, and resource-specific information is appended."
}
},
"instanceCount": {
"type": "int",
"defaultValue": 2,
"maxValue": 20,
"metadata": {
"description": "Number of VM instances (20 or less)."
}
},
"adminUsername": {
"type": "string",
"defaultValue": "azureuser",
"metadata": {
"description": "Admin username on all VMs."
}
},
"adminPassword": {
"type": "secureString",
"defaultValue": "[format('Subscription#{0}', subscription().subscriptionId)]",
"metadata": {
"description": "Admin password on all VMs."
}
},
"osImagePublisher": {
"type": "string",
"defaultValue": "Canonical",
"metadata": {
"description": "Maps to the publisher in the Azure Stack Platform Image Repository manifest file."
}
},
"osImageOffer": {
"type": "string",
"defaultValue": "UbuntuServer",
"metadata": {
"description": "Maps to the Offer in the Azure Stack Platform Image Repository manifest file."
}
},
"osImageSku": {
"type": "string",
"defaultValue": "16.04-LTS",
"metadata": {
"description": "The Ubuntu version for the VM. This will pick a fully patched image of this given Ubuntu version. Default value: 14.04.3-LTS"
}
}
},
"functions": [],
"variables": {
"location": "[resourceGroup().location]",
"vnetName": "[toLower(format('vnet{0}', uniqueString(resourceGroup().id)))]",
"subnetName": "[toLower(format('subnet{0}', uniqueString(resourceGroup().id)))]",
"storageAccountName": "[toLower(format('SA{0}', uniqueString(resourceGroup().id)))]",
"storageAccountContainerName": "[toLower(format('SC{0}', uniqueString(resourceGroup().id)))]",
"storageAccountType": "Standard_LRS",
"OSDiskName": "osdisk",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]",
"subnetRef": "[format('{0}/subnets/{1}', variables('vnetID'), variables('subnetName'))]",
"publicIPAddressName": "[toLower(format('pip{0}', uniqueString(resourceGroup().id)))]",
"vmssDomainName": "[toLower(format('pubdns{0}', uniqueString(resourceGroup().id)))]",
"loadBalancerName": "[format('LB{0}', uniqueString(resourceGroup().id))]",
"loadBalancerFrontEndName": "[format('LBFrontEnd{0}', uniqueString(resourceGroup().id))]",
"loadBalancerBackEndName": "[format('LBBackEnd{0}', uniqueString(resourceGroup().id))]",
"loadBalancerProbeName": "[format('LBHttpProbe{0}', uniqueString(resourceGroup().id))]",
"loadBalancerNatPoolName": "[format('LBNatPool{0}', uniqueString(resourceGroup().id))]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[variables('storageAccountName')]",
"location": "[variables('location')]",
"sku": {
"name": "[variables('storageAccountType')]"
},
"kind": "Storage"
},
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2018-11-01",
"name": "[variables('vnetName')]",
"location": "[variables('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "10.0.0.0/24"
}
}
]
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2018-11-01",
"name": "[variables('publicIPAddressName')]",
"location": "[variables('location')]",
"properties": {
"publicIPAllocationMethod": "Dynamic",
"dnsSettings": {
"domainNameLabel": "[variables('vmssDomainName')]"
}
}
},
{
"type": "Microsoft.Network/loadBalancers",
"apiVersion": "2018-11-01",
"name": "[variables('loadBalancerName')]",
"location": "[variables('location')]",
"properties": {
"frontendIPConfigurations": [
{
"name": "[variables('loadBalancerFrontEndName')]",
"properties": {
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
}
}
}
],
"backendAddressPools": [
{
"name": "[variables('loadBalancerBackEndName')]"
}
],
"loadBalancingRules": [
{
"name": "roundRobinLBRule",
"properties": {
"frontendIPConfiguration": {
"id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('loadBalancerName'), variables('loadBalancerFrontEndName'))]"
},
"backendAddressPool": {
"id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('loadBalancerName'), variables('loadBalancerBackEndName'))]"
},
"protocol": "Tcp",
"frontendPort": 80,
"backendPort": 80,
"enableFloatingIP": false,
"idleTimeoutInMinutes": 5,
"probe": {
"id": "[resourceId('Microsoft.Network/loadBalancers/probes', variables('loadBalancerName'), variables('loadBalancerProbeName'))]"
}
}
}
],
"probes": [
{
"name": "[variables('loadBalancerProbeName')]",
"properties": {
"protocol": "Tcp",
"port": 80,
"intervalInSeconds": 5,
"numberOfProbes": 2
}
}
],
"inboundNatPools": [
{
"name": "[variables('loadBalancerNatPoolName')]",
"properties": {
"frontendIPConfiguration": {
"id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('loadBalancerName'), variables('loadBalancerFrontEndName'))]"
},
"protocol": "Tcp",
"frontendPortRangeStart": 50000,
"frontendPortRangeEnd": 50019,
"backendPort": 3389
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
]
},
{
"type": "Microsoft.Compute/virtualMachineScaleSets",
"apiVersion": "2020-06-01",
"name": "[parameters('vmssName')]",
"sku": {
"name": "[parameters('vmSku')]",
"tier": "Standard",
"capacity": "[parameters('instanceCount')]"
},
"location": "[variables('location')]",
"properties": {
"upgradePolicy": {
"mode": "Manual"
},
"virtualMachineProfile": {
"storageProfile": {
"osDisk": {
"vhdContainers": [
"[concat(reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob, variables('storageAccountContainerName'))]"
],
"name": "[variables('OSDiskName')]",
"caching": "ReadOnly",
"createOption": "FromImage"
},
"imageReference": {
"publisher": "[parameters('osImagePublisher')]",
"offer": "[parameters('osImageOffer')]",
"sku": "[parameters('osImageSku')]",
"version": "latest"
}
},
"osProfile": {
"computerNamePrefix": "[parameters('vmssName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "nic",
"properties": {
"primary": true,
"ipConfigurations": [
{
"name": "ipconfig",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
},
"loadBalancerBackendAddressPools": [
{
"id": "[reference(resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))).backendAddressPools[0].id]"
}
],
"loadBalancerInboundNatPools": [
{
"id": "[reference(resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))).inboundNatPools[0].id]"
}
]
}
}
]
}
}
]
},
"extensionProfile": {
"extensions": [
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[format('{0}-LinuxCustomScriptExtension', parameters('vmssName'))]",
"properties": {
"publisher": "Microsoft.OSTCExtensions",
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.3",
"autoUpgradeMinorVersion": true,
"settings": {
"commandToExecute": "touch /test.txt",
"enableInternalDNSCheck": "false"
}
}
}
]
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]"
]
}
]
}

Просмотреть файл

@ -2,14 +2,12 @@
This template allows you to deploy a VM Scale Set of Windows VMs with a custom script run on each VM. It uses the latest patched version of several Windows versions. To connect from the load balancer to a VM in the scale set, you would go to the AzureStack Portal, find the load balancer of your scale set, examine the NAT rules, then connect using the NAT rule you want. For example, if there is a NAT rule on port 50000, you could RDP on port 50000 of the public IP to connect to that VM. Similarly if something is listening on port 80 we can connect to it using port 80:
PARAMETER RESTRICTIONS
======================
# Parameter Restriction
vmssName must be 3-10 characters in length. It should also be globally unique across all of AzureStack. If it isn't globally unique, it is possible that this template will still deploy properly, but we don't recommend relying on this pseudo-probabilistic behavior.
instanceCount must be 20 or less. VM Scale Set supports upto 100 VMs and one should add more storage accounts to support this number.
Deploy using Az CLI
# Deploy using Az CLI
```Powershell
# update parameters values in azuredeploy.parametrs.json file and run below commands
# create resource group if it doesn't exist

Просмотреть файл

@ -1,315 +0,0 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.4.613.9944",
"templateHash": "313291512184700301"
}
},
"parameters": {
"vmSku": {
"type": "string",
"defaultValue": "Standard_D1",
"metadata": {
"description": "Size of VMs in the VM Scale Set."
}
},
"osImageSku": {
"type": "string",
"defaultValue": "2016-Datacenter",
"allowedValues": [
"2012-R2-Datacenter",
"2016-Datacenter-Server-Core",
"2016-Datacenter"
],
"metadata": {
"description": "The Windows version for the VM. This will pick a fully patched image of this given Windows version. Allowed values: 2008-R2-SP1, 2012-Datacenter, 2012-R2-Datacenter."
}
},
"osImagePublisher": {
"type": "string",
"defaultValue": "MicrosoftWindowsServer",
"metadata": {
"description": "Maps to the publisher in the Azure Stack Platform Image Repository manifest file."
}
},
"osImageOffer": {
"type": "string",
"defaultValue": "WindowsServer",
"metadata": {
"description": "Maps to the Offer in the Azure Stack Platform Image Repository manifest file."
}
},
"vmssName": {
"type": "string",
"defaultValue": "[substring(format('vmss{0}', uniqueString(replace(resourceGroup().id, '-', ''))), 0, 8)]",
"maxLength": 10,
"minLength": 3,
"metadata": {
"description": "String used as a base for naming resources. Must be 3-10 characters in length and globally unique across Azure Stack. A hash is prepended to this string for some resources, and resource-specific information is appended."
}
},
"instanceCount": {
"type": "int",
"defaultValue": 2,
"maxValue": 20,
"metadata": {
"description": "Number of VM instances (20 or less)."
}
},
"adminUsername": {
"type": "string",
"defaultValue": "azureuser",
"metadata": {
"description": "Admin username on all VMs."
}
},
"adminPassword": {
"type": "secureString",
"defaultValue": "[format('Subscription#{0}', subscription().subscriptionId)]",
"metadata": {
"description": "Admin password on all VMs."
}
},
"artifactsLocation": {
"type": "string",
"defaultValue": "https://raw.githubusercontent.com/Azure/azurestack-quickstart-templates/master/201-vmss-windows-extension",
"metadata": {
"description": "The base URI where artifacts required by this template are located. When the template is deployed using the accompanying scripts, a private location in the subscription will be used and this value will be automatically generated."
}
}
},
"functions": [],
"variables": {
"location": "[resourceGroup().location]",
"vnetName": "[toLower(format('vnet{0}', uniqueString(resourceGroup().id)))]",
"subnetName": "[toLower(format('subnet{0}', uniqueString(resourceGroup().id)))]",
"storageAccountName": "[toLower(format('SA{0}', uniqueString(resourceGroup().id)))]",
"storageAccountContainerName": "[toLower(format('SC{0}', uniqueString(resourceGroup().id)))]",
"storageAccountType": "Standard_LRS",
"OSDiskName": "osdisk",
"vnetID": "[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]",
"subnetRef": "[format('{0}/subnets/{1}', variables('vnetID'), variables('subnetName'))]",
"publicIPAddressName": "[toLower(format('pip{0}', uniqueString(resourceGroup().id)))]",
"vmssDomainName": "[toLower(format('pubdns{0}', uniqueString(resourceGroup().id)))]",
"loadBalancerName": "[format('LB{0}', uniqueString(resourceGroup().id))]",
"loadBalancerFrontEndName": "[format('LBFrontEnd{0}', uniqueString(resourceGroup().id))]",
"loadBalancerBackEndName": "[format('LBBackEnd{0}', uniqueString(resourceGroup().id))]",
"loadBalancerProbeName": "[format('LBHttpProbe{0}', uniqueString(resourceGroup().id))]",
"loadBalancerNatPoolName": "[format('LBNatPool{0}', uniqueString(resourceGroup().id))]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[variables('storageAccountName')]",
"location": "[variables('location')]",
"sku": {
"name": "[variables('storageAccountType')]"
},
"kind": "Storage"
},
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2018-11-01",
"name": "[variables('vnetName')]",
"location": "[variables('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"10.0.0.0/16"
]
},
"subnets": [
{
"name": "[variables('subnetName')]",
"properties": {
"addressPrefix": "10.0.0.0/24"
}
}
]
}
},
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2018-11-01",
"name": "[variables('publicIPAddressName')]",
"location": "[variables('location')]",
"properties": {
"publicIPAllocationMethod": "Dynamic",
"dnsSettings": {
"domainNameLabel": "[variables('vmssDomainName')]"
}
}
},
{
"type": "Microsoft.Network/loadBalancers",
"apiVersion": "2018-11-01",
"name": "[variables('loadBalancerName')]",
"location": "[variables('location')]",
"properties": {
"frontendIPConfigurations": [
{
"name": "[variables('loadBalancerFrontEndName')]",
"properties": {
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
}
}
}
],
"backendAddressPools": [
{
"name": "[variables('loadBalancerBackEndName')]"
}
],
"loadBalancingRules": [
{
"name": "roundRobinLBRule",
"properties": {
"frontendIPConfiguration": {
"id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('loadBalancerName'), variables('loadBalancerFrontEndName'))]"
},
"backendAddressPool": {
"id": "[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', variables('loadBalancerName'), variables('loadBalancerBackEndName'))]"
},
"protocol": "Tcp",
"frontendPort": 80,
"backendPort": 80,
"enableFloatingIP": false,
"idleTimeoutInMinutes": 5,
"probe": {
"id": "[resourceId('Microsoft.Network/loadBalancers/probes', variables('loadBalancerName'), variables('loadBalancerProbeName'))]"
}
}
}
],
"probes": [
{
"name": "[variables('loadBalancerProbeName')]",
"properties": {
"protocol": "Tcp",
"port": 80,
"intervalInSeconds": 5,
"numberOfProbes": 2
}
}
],
"inboundNatPools": [
{
"name": "[variables('loadBalancerNatPoolName')]",
"properties": {
"frontendIPConfiguration": {
"id": "[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', variables('loadBalancerName'), variables('loadBalancerFrontEndName'))]"
},
"protocol": "Tcp",
"frontendPortRangeStart": 50000,
"frontendPortRangeEnd": 50019,
"backendPort": 3389
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/publicIPAddresses', variables('publicIPAddressName'))]"
]
},
{
"type": "Microsoft.Compute/virtualMachineScaleSets",
"apiVersion": "2020-06-01",
"name": "[parameters('vmssName')]",
"sku": {
"name": "[parameters('vmSku')]",
"tier": "Standard",
"capacity": "[parameters('instanceCount')]"
},
"location": "[variables('location')]",
"properties": {
"upgradePolicy": {
"mode": "Manual"
},
"virtualMachineProfile": {
"storageProfile": {
"osDisk": {
"vhdContainers": [
"[format('{0}{1}', reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob, variables('storageAccountContainerName'))]"
],
"name": "[variables('OSDiskName')]",
"caching": "ReadOnly",
"createOption": "FromImage"
},
"imageReference": {
"publisher": "[parameters('osImagePublisher')]",
"offer": "[parameters('osImageOffer')]",
"sku": "[parameters('osImageSku')]",
"version": "latest"
}
},
"osProfile": {
"computerNamePrefix": "[parameters('vmssName')]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"networkProfile": {
"networkInterfaceConfigurations": [
{
"name": "nic",
"properties": {
"primary": true,
"ipConfigurations": [
{
"name": "ipconfig",
"properties": {
"subnet": {
"id": "[variables('subnetRef')]"
},
"loadBalancerBackendAddressPools": [
{
"id": "[reference(resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))).backendAddressPools[0].id]"
}
],
"loadBalancerInboundNatPools": [
{
"id": "[reference(resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))).inboundNatPools[0].id]"
}
]
}
}
]
}
}
]
},
"extensionProfile": {
"extensions": [
{
"name": "customScript",
"properties": {
"publisher": "Microsoft.Compute",
"type": "CustomScriptExtension",
"settings": {
"fileUris": [
"[format('{0}/scripts/helloWorld.ps1', parameters('artifactsLocation'))]"
]
},
"typeHandlerVersion": "1.8",
"autoUpgradeMinorVersion": true,
"protectedSettings": {
"commandToExecute": "powershell -ExecutionPolicy Unrestricted -File helloWorld.ps1"
}
}
}
]
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Network/loadBalancers', variables('loadBalancerName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
"[resourceId('Microsoft.Network/virtualNetworks', variables('vnetName'))]"
]
}
]
}

19
Bicep/README.md Normal file
Просмотреть файл

@ -0,0 +1,19 @@
This directory contains Bicep samples for AzureStack
To convert any AzureStack ARM template to Bicep, add api version within each resource declaration. API profile is not yet supported in Bicep. Here is the [tracking feature request](https://github.com/Azure/bicep/issues/851).
Main categories of error during conversion:
1. Error BCP079: This expression is referencing its own declaration, which is not allowed.
* Workaround - [GitHub issue](https://github.com/Azure/bicep/issues/1860)
2. Error BCP034: The enclosing array expected an item of type "module[] | (resource | module) | resource[]", but the provided item was of type "string".
* This is when bicep decompile is not able to recognize the dependent resource and tries to convert the “dependsOn” defined in ARM template. The workaround is to modify the generated bicep template to either create implicit dependency or add the resource (not the resource id as used in ARM template) in dependsOn parameter. [Doc link](https://docs.microsoft.com/en-us/azure/azure-resource-manager/bicep/compare-template-syntax#resource-dependencies)
Az CLI Bicep commands
```
# Convert ARM template to Bicep template
az bicep decompile --file .\azuredeploy.json
# Generate ARM template from Bicep template
az bicep build --file .\azuredeploy.bicep --outfile bicepgenerated.json
# Deploy ARM/Bicep template
az deployment group create --resource-group testrg --template-file <ARM/Bicep template> --parameters .\azuredeploy.parameters.json
```