Skip to content

Commit

Permalink
Merge pull request #465 from JCoreMS/JCore-Brownfield-AppAttachToolsVM
Browse files Browse the repository at this point in the history
Brownfield New App Attach Tools VM - JCore
  • Loading branch information
danycontre authored Sep 19, 2023
2 parents 7ec34fa + 360aacb commit 919edd8
Show file tree
Hide file tree
Showing 8 changed files with 5,304 additions and 4 deletions.
4,550 changes: 4,550 additions & 0 deletions workload/arm/brownfield/deployAppAttachToolsVM.json

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions workload/bicep/brownfield/alerts/readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
## Table of Contents

| [Home](../../../../readme.md) | [Custom Image Build](/workload/docs/getting-started-custom-image-build.md) | [Auto Increase Premium File Share Quota](/workload/bicep/brownfield/autoIncreasePremiumFileShareQuota/readme.md) | [Scaling Tool](/workload/bicep/brownfield/scalingTool/readme.md) | [Start VM On Connect](/workload/bicep/brownfield/startVmOnConnect/readme.md) | [Deep Insights Workbook](/workload/workbooks/deepInsightsWorkbook/readme.md) |

# AVD Alerts Solution

[Alerts Home](./readme.md) | [PostDeployment](./postDeploy.md) | [How to Change Thresholds](./changeAlertThreshold.md) | [Alert Reference](./alertReference.md) | [Excel List of Alert Rules](./references/alerts.xlsx) | [Update History](./updateHistory.md)
Expand Down
59 changes: 59 additions & 0 deletions workload/bicep/brownfield/appAttachToolsVM/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Deploy Azure VM with MSIX App Attach Tools
This deployment will create a VM from the Microsoft Gallery and configure and install software for use when creating MSIX App attach images.
- MSIX App Attach Store App
- MSIX Manager command line tool
- PSFTooling App
- Disables Plug and Play service (prevents new disk pop-up when mounting VHDs)
- Creates C:\MSIX directory with apps and script to convert MSIX to VHD
- Creates a self-signed certificate and places it within the "Trusted People Store" for signing packages
(Consider a Certificate from a Certificate Authority for Production Use)

## Pre-requisites

- Azure Tenant and Subscription
- Resource Group
- VNet and Subnet

## Deployment

The easiest method is to configure the deployment via the provided blue buttons as they include the custom UI for configuring the options. However, you can also utilize PowerShell and the Azure CLI.

### Azure Portal UI

[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#blade/Microsoft_Azure_CreateUIDef/CustomDeploymentBlade/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Favdaccelerator%2Fmain%2Fworkload%2Farm%2Fbrownfield%2FdeployAppAttachToolsVM.json/uiFormDefinitionUri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Favdaccelerator%2Fmain%2Fworkload%2Fportal-ui%2Fbrownfield%2FportalUiAppAttachToolsVM.json) [![Deploy to Azure Gov](https://aka.ms/deploytoazuregovbutton)](https://portal.azure.us/#blade/Microsoft_Azure_CreateUIDef/CustomDeploymentBlade/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Favdaccelerator%2Fmain%2Fworkload%2Farm%2Fbrownfield%2FdeployAppAttachToolsVM.json/uiFormDefinitionUri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Favdaccelerator%2Fmain%2Fworkload%2Fportal-ui%2Fbrownfield%2FportalUiAppAttachToolsVM.json)

### PowerShell

```powershell
New-AzDeployment `
-Location '<Azure location>' `
-TemplateFile 'https://raw.githubusercontent.com/Azure/avdaccelerator/main/workload/arm/brownfield/deployAppAttachToolsVM.json' `
-adminUsername '<Local Admin User Name>' `
-adminPassUseKv false `
-adminPassword '<Password for Local Admin Account>' `
-publicIPAllowed '<true or false (Determines if NIC will have a Public IP Address)>' `
-OSoffer 'WindowsDesktop' `
-SubnetName '<Name of Subnet where VM will be attached.>' `
-vmDiskType '<Standard_LRS, StandardSSD_LRS or Premium_LRS>' `
-vmName '<Name for VM>' `
-VNet '<Object value surrounded by {} with comma seperated key pairs for desired VNet name, id, location and subscriptionName>' `
-Verbose
```

### Azure CLI

```azurecli
az deployment sub create \
--location '<Azure location>' \
--template-uri 'https://raw.githubusercontent.com/Azure/avdaccelerator/main/workload/arm/brownfield/deployAppAttachToolsVM.json' \
--parameters \
-adminUsername '<Local Admin User Name>' \
-adminPassUseKv false \
-adminPassword '<Password for Local Admin Account>' \
-publicIPAllowed '<true or false (Determines if NIC will have a Public IP Address)>' \
-OSoffer 'WindowsDesktop' \
-SubnetName '<Name of Subnet where VM will be attached.>' \
-vmDiskType '<Standard_LRS, StandardSSD_LRS or Premium_LRS>' \
-vmName '<Name for VM>' \
-VNet '<Object value surrounded by {} with comma seperated key pairs for desired VNet name, id, location and subscriptionName>'
```
74 changes: 74 additions & 0 deletions workload/bicep/brownfield/appAttachToolsVM/modules/VM.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
param AdminUserName string
@secure()
param AdminPassword string
param Location string
param OSoffer string
param OSVersion string
param PostDeployScriptURI string
param UsePublicIP bool
param VMDiskType string
param VMName string
param VMSize string
param VMSubResId string


var IPConfig = UsePublicIP ? {
name: 'ipconfig1'
subnetResourceId: VMSubResId
pipConfiguration: {
publicIpNameSuffix: '-pip-01'
deleteOption: 'Delete'
}
} : {
name: 'ipconfig1'
subnetResourceId: VMSubResId
}


module virtualMachine '../../../../../carml/1.3.0/Microsoft.Compute/virtualMachines/deploy.bicep' = {
name: 'c_${VMName}_DeployAndConfig'
params: {
name: VMName
location: Location
adminUsername: AdminUserName
adminPassword: AdminPassword
secureBootEnabled: true
securityType: 'TrustedLaunch'
encryptionAtHost: false
vTpmEnabled: true
imageReference: {
publisher: 'MicrosoftWindowsDesktop'
offer: OSoffer
sku: OSVersion
version: 'latest'
}
nicConfigurations: [
{
nicSuffix: '${VMName}-nic-01'
deleteOption: 'Delete'
ipConfigurations: [ IPConfig ]
}
]
osDisk: {
createOption: 'FromImage'
deleteOption: 'Delete'
managedDisk: {
storageAccountType: VMDiskType
}
diskSizeGB: 127
}
osType: 'Windows'
vmSize: VMSize
extensionCustomScriptConfig: {
enabled: true
fileData: [
{
uri: '${PostDeployScriptURI}AppAttachVMConfig.ps1'
}
]
}
extensionCustomScriptProtectedSetting: {
commandToExecute: 'powershell -ExecutionPolicy Unrestricted -File AppAttachVMConfig.ps1 -VMUserName ${AdminUserName} -VMUserPassword ${AdminPassword} -PostDeployScriptURI ${PostDeployScriptURI}'
}
}
}
76 changes: 76 additions & 0 deletions workload/bicep/brownfield/appAttachToolsVM/solution.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
@description('Username for the Virtual Machine.')
param adminUsername string = 'vmadmin'

@description('Keyvault Option for Local Admin Password.')
param adminPassUseKv bool = false

param adminPassKv object = {}
param adminPassKvSecret string = ''

@description('Password for the Virtual Machine.')
@minLength(12)
@secure()
param adminPassword string = newGuid()

@description('Create the VM with a Public IP to access the Virtual Machine?')
param publicIPAllowed bool = false

@description('The Windows version for the VM.')
param OSoffer string

@description('The Windows build version for the VM.')
param OSVersion string = 'win11-22h2-ent'

@description('Size of the virtual machine.')
param vmDiskType string

@description('Size of the virtual machine.')
param vmSize string = 'Standard_D2s_v5'

@description('Location for all resources.')
param location string = resourceGroup().location

@description('Name of the virtual machine. (must be 15 characters or less)')
@maxLength(15)
param vmName string = 'vmAppAttach01'

@description('Virtual Network to attach MSIX Tools VM to.')
param VNet object = {
name: ''
id: ''
location: ''
subscriptionName: ''
}

@description('Subnet to use for MSIX VM Tools VM.')
param SubnetName string

var PostDeployScriptURI = 'https://github.com/Azure/avdaccelerator/blob/main/workload/scripts/appAttachToolsVM/'
var VNetSub = split(VNet.id, '/')[2]
var VNetRG = split(VNet.id, '/')[4]
var VNetName = VNet.name
var KVLocalAdminSubId = adminPassUseKv ? split(adminPassKv.id, '/')[2] : ''
var KVLocalAdminRG = adminPassUseKv ? split(adminPassKv.id, '/')[4] : ''

resource kvVMPassword 'Microsoft.KeyVault/vaults@2023-02-01' existing = if(adminPassUseKv) {
name: adminPassKv.name
scope: resourceGroup(KVLocalAdminSubId, KVLocalAdminRG)
}

module vmDeploy './modules/VM.bicep' = {
name: 'linked_${vmName}_Deployment'
params: {
AdminUserName: adminUsername
AdminPassword: adminPassUseKv ? kvVMPassword.getSecret(adminPassKvSecret) : adminPassword
Location: location
OSoffer: OSoffer
OSVersion: OSVersion
PostDeployScriptURI: PostDeployScriptURI
UsePublicIP: publicIPAllowed
VMDiskType: vmDiskType
VMName: vmName
VMSubResId: resourceId(VNetSub, VNetRG, 'Microsoft.VirtualNetwork/virtualNetworks/subnets', VNetName, SubnetName)
VMSize: vmSize
}
}

Loading

0 comments on commit 919edd8

Please sign in to comment.