Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

win vm proxy hci #14136

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
description: This template creates a Windows VM with a proxy configuration from the referenced Azure Marketplace image on Azure Stack HCI version 23H2+
page_type: sample
products:
- azure
- azure-resource-manager
urlFragment: vm-proxy-ashci-windows
languages:
- bicep
- json
---
# Create a VM with proxy from the referenced image on Azure Stack HCI

![Azure Public Test Date](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azurestackhci/vm-proxy-ashci-windows/PublicLastTestDate.svg)
![Azure Public Test Result](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azurestackhci/vm-proxy-ashci-windows/PublicDeployment.svg)

![Azure US Gov Last Test Date](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azurestackhci/vm-proxy-ashci-windows/FairfaxLastTestDate.svg)
![Azure US Gov Last Test Result](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azurestackhci/vm-proxy-ashci-windows/FairfaxDeployment.svg)

![Best Practice Check](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azurestackhci/vm-proxy-ashci-windows/BestPracticeResult.svg)
![Cred Scan Check](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azurestackhci/vm-proxy-ashci-windows/CredScanResult.svg)

![Bicep Version](https://azurequickstartsservice.blob.core.windows.net/badges/quickstarts/microsoft.azurestackhci/vm-proxy-ashci-windows/BicepVersion.svg)

This template allows you to deploy a new Windows Virtual Machine on an on-premises Azure Stack HCI cluster running 23H2 or newer using the referenced Azure Marketplace image, configuring HTTP and HTTPS proxy settings. The [article](/azure-stack/hci/manage/manage-virtual-machines-in-azure-portal?tabs=arm) walks you through the process and prerequisites.

[![Deploy To Azure](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/deploytoazure.svg?sanitize=true)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fquickstarts%2Fmicrosoft.azurestackhci%2Fvm-proxy-ashci-windows%2Fazuredeploy.json)
[![Deploy To Azure US Gov](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/deploytoazuregov.svg?sanitize=true)](https://portal.azure.us/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fquickstarts%2Fmicrosoft.azurestackhci%2Fvm-proxy-ashci-windows%2Fazuredeploy.json)
[![Visualize](https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/1-CONTRIBUTION-GUIDE/images/visualizebutton.svg?sanitize=true)](http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fquickstarts%2Fmicrosoft.azurestackhci%2Fvm-proxy-ashci-windows%2Fazuredeploy.json)

## Prerequisites

In order to deploy this template, there must be an operational ARC Resource Bridge associated with your Azure Stack HCI cluster. The Azure Stack HCI 23H2 and later deployment process will configure the Resource Bridge for you, but you will need to have manually created the Logical Network and Image.

- Custom Location: This is the custom location resource representing your Azure Stack HCI Cluster in Azure. The following Virtual Network and Image resources must be associated with this custom location.
- Azure Stack HCI Logical Network: This resource is the Azure representation of your Hyper-v virtual switch and related network configuration used for the Network Interface created for the new VM. See [Azure Stack HCI Virtual Networks](/azure-stack/hci/manage/create-logical-networks)
- Azure Stack HCI Image: This is a virtual machine image, created from an Azure marketplace gallery image. See [Azure Stack HCI Images](/azure-stack/hci/manage/virtual-machine-image-azure-marketplace)

> [!NOTE]
> For simplicity, this template assumes the Custom Location, Virtual Network, and Image all reside in the same Resource Group as where the Virtual Machine is being created.

`Tags: Microsoft.AzureStackHCI/virtualmachines, hci`
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "vm-sampledeploy"
},
"location": {
"value": "eastus"
},
"adminUsername": {
"value": "admin-quickstart"
},
"adminPassword": {
"value": "GEN-PASSWORD"
},
"vCPUCount": {
"value": 2
},
"memoryMB": {
"value": 4096
},
"imageName": {
"value": "GEN-UNIQUE"
},
"hciLogicalNetworkName": {
"value": "GEN-UNIQUE"
},
"customLocationName": {
"value": "GEN-UNIQUE"
},
"proxyHTTP": {
"value": "http://proxy.contoso.com:8080"
},
"proxyHTTPS": {
"value": "http://proxy.contoso.com:8080"
},
"proxyBypass": {
"value": ["localhost"]
}
}
}
101 changes: 101 additions & 0 deletions quickstarts/microsoft.azurestackhci/vm-proxy-ashci-windows/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
@maxLength(15)
param name string
param location string
param vCPUCount int = 2
param memoryMB int = 8192
param adminUsername string
@description('The name of a Marketplace Gallery Image already downloaded to the Azure Stack HCI cluster. For example: winServer2022-01')
param imageName string
@description('The name of an existing Logical Network in your HCI cluster - for example: vnet-compute-vlan240-dhcp')
param hciLogicalNetworkName string
@description('The name of the custom location to use for the deployment. This name is specified during the deployment of the Azure Stack HCI cluster and can be found on the Azure Stack HCI cluster resource Overview in the Azure portal.')
param customLocationName string
@secure()
param adminPassword string
@description('Optional. Proxy server URL for the VM to use for HTTP traffic. Example: http://proxy.contoso.com:8080')
param httpProxy string?
@description('Optional. Proxy server URL for the VM to use for HTTPS traffic. Example: http://proxy.contoso.com:8080')
param httpsProxy string?
@description('Optional. Array of URLs that the VM should not use the proxy server for. Example: ["localhost", "172.16.0.0/12"]')
param noProxy array?
@description('Optional. Trusted CA certificate for the proxy server. Example: "-----BEGIN CERTIFICATE-----\nMIIDdzCCAl..."')
param trustedProxyCA string?

var nicName = 'nic-${name}' // name of the NIC to be created
var customLocationId = resourceId('Microsoft.ExtendedLocation/customLocations', customLocationName) // full custom location ID
var marketplaceGalleryImageId = resourceId('microsoft.azurestackhci/marketplaceGalleryImages', imageName) // full marketplace gallery image ID
var logicalNetworkId = resourceId('microsoft.azurestackhci/logicalnetworks', hciLogicalNetworkName) // full logical network ID

// precreate an Arc Connected Machine with an identity--used for zero-touch onboarding of the Arc VM during deployment
resource hybridComputeMachine 'Microsoft.HybridCompute/machines@2023-10-03-preview' = {
name: name
location: location
kind: 'HCI'
identity: {
type: 'SystemAssigned'
}
}

resource nic 'Microsoft.AzureStackHCI/networkInterfaces@2024-01-01' = {
name: nicName
location: location
extendedLocation: {
type: 'CustomLocation'
name: customLocationId
}
properties: {
ipConfigurations: [
{
name: 'ipconfig1'
properties: {
subnet: {
id: logicalNetworkId
}
}
}
]
}
}

resource virtualMachine 'Microsoft.AzureStackHCI/virtualMachineInstances@2024-01-01' = {
name: 'default' // value must be 'default' per 2023-09-01-preview
properties: {
hardwareProfile: {
vmSize: 'Custom'
processors: vCPUCount
memoryMB: memoryMB
}
httpProxyConfig: {
httpProxy: httpProxy
httpsProxy: httpsProxy
noProxy: noProxy
trustedCa: trustedProxyCA
}
osProfile: {
adminUsername: adminUsername
adminPassword: adminPassword
computerName: name
windowsConfiguration: {
provisionVMAgent: true // mocguestagent
provisionVMConfigAgent: true // azure arc connected machine agent
}
}
storageProfile: {
imageReference: {
id: marketplaceGalleryImageId
}
}
networkProfile: {
networkInterfaces: [
{
id: nic.id
}
]
}
}
extendedLocation: {
type: 'CustomLocation'
name: customLocationId
}
scope: hybridComputeMachine
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://aka.ms/azure-quickstart-templates-metadata-schema#",
"type": "QuickStart",
"itemDisplayName": "Create a VM with proxy config on Azure Stack HCI",
"description": "This template creates a Windows VM with a proxy configuration on Azure Stack HCI version 23H2+",
"summary": "Create a VM from the referenced image on Azure Stack HCI",
"githubUsername": "mbrat2005",
"validationType": "Manual",
"dateUpdated": "2024-09-05"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"value": "eastus"
},
"customLocationName": {
"value": "GEN-UNIQUE"
},
"logicalNetworkName": {
"value": "vnet-vlan240"
},
"vmSwitchName": {
"value": "ConvergedSwitch"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
@description('The name of an existing Logical Network in your HCI cluster - for example: vnet-compute-vlan240-dhcp')
param logicalNetworkName string
@description('The name of a Hyper-V VM switch in your HCI cluster - usually serving your Compute network. For example: ComputeSwitch(compute)')
param vmSwitchName string
@description('The DNS servers to use for the logical network. Make sure to use local DNS servers for AD-joined systems')
param dnsServers array = [
'1.1.1.1'
'8.8.8.8'
]
@description('The VLAN ID for the logical network. If not specified, the default value is 0.')
param vlan int = 0
@description('The address prefix for the logical network - for example: 172.16.0.0/22')
param addressPrefix string
@description('The default gateway for the logical network - for example: 172.16.0.1')
param defaultGateway string
@description('The start IP address for the IP pool - for example: 172.16.1.100')
param startIPAddress string
@description('The start IP address for the IP pool - for example: 172.16.1.200')
param endIPAddress string
param location string = 'eastus'
@description('The name of the custom location to use for the deployment. This name is specified during the deployment of the Azure Stack HCI cluster and can be found on the Azure Stack HCI cluster resource Overview in the Azure portal.')
param customLocationName string

var customLocationId = resourceId('Microsoft.ExtendedLocation/customLocations', customLocationName)

resource marketplaceGalleryImage 'Microsoft.AzureStackHCI/marketplaceGalleryImages@2023-09-01-preview' = {
name: 'MicrosoftWindowsServer'
location: location
extendedLocation: {
type: 'CustomLocation'
name: customLocationId
}
properties: {
identifier: {
publisher: 'microsoftwindowsserver'
offer: 'windowsserver'
sku: '2022-datacenter-azure-edition'
}
version: {
name: 'latest'
}
osType: 'Windows'
}
}

resource virtualNetwork 'Microsoft.AzureStackHCI/logicalNetworks@2023-09-01-preview' = {
name: logicalNetworkName
location: location
extendedLocation: {
type: 'CustomLocation'
name: customLocationId
}
properties: {
subnets: [ {
name: 'default'
properties: {
addressPrefix: addressPrefix
ipAllocationMethod: 'Dynamic'
vlan: vlan
ipPools: [
{
start: startIPAddress
end: endIPAddress
}
]
routeTable: {
properties: {
routes: [
{
name: 'default'
properties: {
addressPrefix: '0.0.0.0/0'
nextHopIpAddress: defaultGateway
}
}
]
}
}
}
} ]
vmSwitchName: vmSwitchName
dhcpOptions: {
dnsServers: dnsServers
}
}
}
Loading