Skip to content

Commit

Permalink
Remove VM (Azure-Samples#1852)
Browse files Browse the repository at this point in the history
  • Loading branch information
pamelafox authored Jul 22, 2024
1 parent 3dc31ce commit 0a62d10
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 226 deletions.
16 changes: 1 addition & 15 deletions docs/deploy_private.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@

If you want to disable public access when deploying the Chat App, you can do so by setting `azd` environment values.

[📺 Watch a video overview of the VM provisioning process](https://www.youtube.com/watch?v=RbITd0a5who)

## Before you begin

Deploying with public access disabled adds additional cost to your deployment. Please see pricing for the following products:

1. [Private Endpoints](https://azure.microsoft.com/pricing/details/private-link/)
1. The exact number of private endpoints created depends on the [optional features](./deploy_features.md) used.
1. [Private DNS Zones](https://azure.microsoft.com/pricing/details/dns/)
1. (Optional, but recommended)[Azure Virtual Machines](https://azure.microsoft.com/pricing/details/virtual-machines/windows/)
1. (Optional, but recommended)[Azure Bastion](https://azure.microsoft.com/pricing/details/azure-bastion/)

## Environment variables controlling private access

Expand All @@ -23,13 +19,6 @@ Deploying with public access disabled adds additional cost to your deployment. P
1. `AZURE_USE_PRIVATE_ENDPOINT`: Controls deployment of [private endpoints](https://learn.microsoft.com/azure/private-link/private-endpoint-overview) which connect Azure resources to the virtual network.
1. When set to 'true', ensures private endpoints are deployed for connectivity even when `AZURE_PUBLIC_NETWORK_ACCESS` is 'Disabled'.
1. Note that private endpoints do not make the chat app accessible from the internet. Connections must be initiated from inside the virtual network.
1. `AZURE_PROVISION_VM`: Controls deployment of a [virtual machine](https://learn.microsoft.com/azure/virtual-machines/overview) and [Azure Bastion](https://learn.microsoft.com/azure/bastion/bastion-overview). Azure Bastion allows you to securely connect to the virtual machine, without being connected virtual network. Since the virtual machine is connected to the virtual network, you are able to access the chat app.
1. You must set `AZURE_VM_USERNAME` and `AZURE_VM_PASSWORD` to provision the built-in administrator account with the virtual machine so you can log in through Azure Bastion.
1. By default, a server version of Windows is used for the VM. If you need to [enroll your device in Microsoft Intune](https://learn.microsoft.com/mem/intune/user-help/enroll-windows-10-device), you should use a desktop version of Windows by setting the following environment variables:

* `azd env set AZURE_VM_OS_PUBLISHER MicrosoftWindowsDesktop`
* `azd env set AZURE_VM_OS_OFFER Windows-11`
* `azd env set AZURE_VM_OS_VERSION win11-23h2-pro`

## Recommended deployment strategy for private access

Expand All @@ -46,10 +35,7 @@ Deploying with public access disabled adds additional cost to your deployment. P

```shell
azd env set AZURE_PUBLIC_NETWORK_ACCESS Disabled
azd env set AZURE_PROVISION_VM true # Optional but recommended
azd env set AZURE_VM_USERNAME myadminusername # https://learn.microsoft.com/azure/virtual-machines/windows/faq#what-are-the-username-requirements-when-creating-a-vm-
azd env set AZURE_VM_PASSWORD mypassword # https://learn.microsoft.com/azure/virtual-machines/windows/faq#what-are-the-password-requirements-when-creating-a-vm-
azd provision
```

1. Log into your new VM using [Azure Bastion](https://learn.microsoft.com/azure/bastion/tutorial-create-host-portal#connect). Validate the chat app is accessible from the virtual machine using a web browser.
1. Log into your network using a tool like [Azure VPN Gateway](https://azure.microsoft.com/services/vpn-gateway/) and validate that you can connect to the chat app from inside the network.
68 changes: 0 additions & 68 deletions infra/core/host/vm.bicep

This file was deleted.

24 changes: 0 additions & 24 deletions infra/core/networking/bastion.bicep

This file was deleted.

15 changes: 0 additions & 15 deletions infra/core/networking/ip.bicep

This file was deleted.

23 changes: 0 additions & 23 deletions infra/core/networking/nic.bicep

This file was deleted.

29 changes: 0 additions & 29 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,6 @@ param publicNetworkAccess string = 'Enabled'
@description('Add a private endpoints for network connectivity')
param usePrivateEndpoint bool = false

@description('Provision a VM to use for private endpoint connectivity')
param provisionVm bool = false
param vmUserName string = ''
@secure()
param vmPassword string = ''
param vmOsVersion string = ''
param vmOsPublisher string = ''
param vmOsOffer string = ''
@description('Size of the virtual machine.')
param vmSize string = 'Standard_DS1_v2'

@description('Id of the user or app to assign application roles')
param principalId string = ''

Expand Down Expand Up @@ -716,10 +705,8 @@ module isolation 'network-isolation.bicep' = {
params: {
location: location
tags: tags
resourceToken: resourceToken
vnetName: '${abbrs.virtualNetworks}${resourceToken}'
appServicePlanName: appServicePlan.outputs.name
provisionVm: provisionVm
usePrivateEndpoint: usePrivateEndpoint
}
}
Expand Down Expand Up @@ -774,22 +761,6 @@ module privateEndpoints 'private-endpoints.bicep' = if (usePrivateEndpoint) {
}
}

module vm 'core/host/vm.bicep' = if (provisionVm && usePrivateEndpoint) {
name: 'vm'
scope: resourceGroup
params: {
name: '${abbrs.computeVirtualMachines}${resourceToken}'
location: location
adminUsername: vmUserName
adminPassword: vmPassword
nicId: isolation.outputs.nicId
osVersion: vmOsVersion
osPublisher: vmOsPublisher
osOffer: vmOsOffer
vmSize: vmSize
}
}

// Used to read index definitions (required when using authentication)
// https://learn.microsoft.com/azure/search/search-security-rbac
module searchReaderRoleBackend 'core/security/role.bicep' = if (useAuthentication) {
Expand Down
18 changes: 0 additions & 18 deletions infra/main.parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -215,24 +215,6 @@
"bypass": {
"value": "${AZURE_NETWORK_BYPASS=AzureServices}"
},
"provisionVm": {
"value": "${AZURE_PROVISION_VM=false}"
},
"vmUserName": {
"value": "${AZURE_VM_USERNAME}"
},
"vmPassword": {
"value": "${AZURE_VM_PASSWORD}"
},
"vmOsVersion": {
"value": "${AZURE_VM_OS_VERSION=2022-datacenter-azure-edition}"
},
"vmOsPublisher": {
"value": "${AZURE_VM_OS_PUBLISHER=MicrosoftWindowsServer}"
},
"vmOsOffer": {
"value": "${AZURE_VM_OS_OFFER=WindowsServer}"
},
"useIntegratedVectorization": {
"value": "${USE_FEATURE_INT_VECTORIZATION}"
},
Expand Down
34 changes: 0 additions & 34 deletions infra/network-isolation.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,8 @@ param tags object = {}
@description('The name of an existing App Service Plan to connect to the VNet')
param appServicePlanName string

@description('A unique token to append to the end of all resource names')
param resourceToken string

param provisionVm bool = false

param usePrivateEndpoint bool = false

var abbrs = loadJsonContent('abbreviations.json')

resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' existing = {
name: appServicePlanName
}
Expand Down Expand Up @@ -75,34 +68,7 @@ module vnet './core/networking/vnet.bicep' = if (usePrivateEndpoint) {
}
}

module nic 'core/networking/nic.bicep' = if (usePrivateEndpoint && provisionVm) {
name: 'nic'
params: {
name: '${abbrs.networkNetworkInterfaces}${resourceToken}'
location: location
subnetId: usePrivateEndpoint ? vnet.outputs.vnetSubnets[3].id : ''
}
}

module publicIp 'core/networking/ip.bicep' = if (usePrivateEndpoint && provisionVm) {
name: 'ip'
params: {
name: '${abbrs.networkPublicIPAddresses}${resourceToken}'
location: location
}
}

module bastion 'core/networking/bastion.bicep' = if (usePrivateEndpoint && provisionVm) {
name: 'bastion'
params: {
name: '${abbrs.networkBastionHosts}${resourceToken}'
location: location
subnetId: usePrivateEndpoint ? vnet.outputs.vnetSubnets[1].id : ''
publicIPId: provisionVm ? publicIp.outputs.id : ''
}
}

output appSubnetId string = usePrivateEndpoint ? vnet.outputs.vnetSubnets[2].id : ''
output backendSubnetId string = usePrivateEndpoint ? vnet.outputs.vnetSubnets[0].id : ''
output vnetName string = usePrivateEndpoint ? vnet.outputs.name : ''
output nicId string = provisionVm && usePrivateEndpoint ? nic.outputs.id : ''

0 comments on commit 0a62d10

Please sign in to comment.