Skip to content

Commit

Permalink
merged upstream changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jwaltireland committed Jan 6, 2025
2 parents 1c62d0f + 57cce4d commit 34abc08
Show file tree
Hide file tree
Showing 29 changed files with 8,321 additions and 9,438 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ $AzureManagementHeader = @{
$ScalingPlanExists = (Invoke-RestMethod `
-Headers $AzureManagementHeader `
-Method 'GET' `
-Uri $($ResourceManagerUriFixed + 'subscriptions/' + $SubscriptionId + '/resourceGroups/' + $ResourceGroupName + '/providers/Microsoft.DesktopVirtualization/scalingPlans?api-version=2024-04-03')).value | Where-Object {$_.name -eq $ScalingPlanName}
-Uri $($ResourceManagerUriFixed + 'subscriptions/' + $SubscriptionId + '/resourceGroups/' + $ResourceGroupName + '/providers/Microsoft.DesktopVirtualization/scalingPlans?api-version=2023-09-05')).value | Where-Object {$_.name -eq $ScalingPlanName}

# Disable autoscale for the host pool: https://learn.microsoft.com/rest/api/desktopvirtualization/scaling-plans/update
if ($ScalingPlanExists)
{
Invoke-RestMethod `
-Body (@{properties = @{hostPoolReferences = @(@{hostPoolArmPath = $HostPoolResourceId; scalingPlanEnabled = $false})}} | ConvertTo-Json) `
-Body (@{properties = @{hostPoolReferences = @(@{hostPoolArmPath = $HostPoolResourceId; scalingPlanEnabled = $false})}} | ConvertTo-Json -Depth 3) `
-Headers $AzureManagementHeader `
-Method 'PATCH' `
-Uri $($ResourceManagerUriFixed + 'subscriptions/' + $SubscriptionId + '/resourceGroups/' + $ResourceGroupName + '/providers/Microsoft.DesktopVirtualization/scalingPlans/' + $ScalingPlanName + '?api-version=2024-04-03') | Out-Null
-Uri $($ResourceManagerUriFixed + 'subscriptions/' + $SubscriptionId + '/resourceGroups/' + $ResourceGroupName + '/providers/Microsoft.DesktopVirtualization/scalingPlans/' + $ScalingPlanName + '?api-version=2023-09-05') | Out-Null
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ param (
[string]$ImageOffer,
[string]$ImagePublisher,
[string]$ImageSku,
[string]$ResourceManagerUri
[string]$ResourceManagerUri,
[string]$SubscriptionId,
[string]$UserAssignedIdentityClientId
)

# Fix the resource manager URI since only AzureCloud contains a trailing slash
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ param encryptionUserAssignedIdentityResourceId string
param fileShares array
param fslogixShareSizeInGB int
param fslogixContainerType string
param fslogixStorageService string
param functionAppName string
param hostPoolName string
param hostPoolResourceId string
param keyVaultUri string
param location string
param managementVirtualMachineName string
Expand All @@ -23,9 +21,7 @@ param namingConvention object
param netbios string
param organizationalUnitPath string
param recoveryServicesVaultName string
param resourceGroupControlPlane string
param resourceGroupManagement string
param resourceGroupStorage string
param securityPrincipalObjectIds array
param securityPrincipalNames array
param serviceToken string
Expand All @@ -51,10 +47,10 @@ var smbSettings = {
}
var storageAccountNamePrefix = uniqueString(replace(namingConvention.storageAccount, serviceToken, 'file-fslogix'), resourceGroup().id)
var storageRedundancy = availability == 'availabilityZones' ? '_ZRS' : '_LRS'
var tagsPrivateEndpoints = union({'cm-resource-parent': '${subscription().id}}/resourceGroups/${resourceGroupControlPlane}/providers/Microsoft.DesktopVirtualization/hostpools/${hostPoolName}'}, contains(tags, 'Microsoft.Network/privateEndpoints') ? tags['Microsoft.Network/privateEndpoints'] : {}, mlzTags)
var tagsStorageAccounts = union({'cm-resource-parent': '${subscription().id}}/resourceGroups/${resourceGroupControlPlane}/providers/Microsoft.DesktopVirtualization/hostpools/${hostPoolName}'}, contains(tags, 'Microsoft.Storage/storageAccounts') ? tags['Microsoft.Storage/storageAccounts'] : {}, mlzTags)
var tagsRecoveryServicesVault = union({'cm-resource-parent': '${subscription().id}}/resourceGroups/${resourceGroupControlPlane}/providers/Microsoft.DesktopVirtualization/hostpools/${hostPoolName}'}, contains(tags, 'Microsoft.recoveryServices/vaults') ? tags['Microsoft.recoveryServices/vaults'] : {}, mlzTags)
var tagsVirtualMachines = union({'cm-resource-parent': '${subscription().id}}/resourceGroups/${resourceGroupControlPlane}/providers/Microsoft.DesktopVirtualization/hostpools/${hostPoolName}'}, contains(tags, 'Microsoft.Compute/virtualMachines') ? tags['Microsoft.Compute/virtualMachines'] : {}, mlzTags)
var tagsPrivateEndpoints = union({'cm-resource-parent': hostPoolResourceId}, tags[?'Microsoft.Network/privateEndpoints'] ?? {}, mlzTags)
var tagsStorageAccounts = union({'cm-resource-parent': hostPoolResourceId}, tags[?'Microsoft.Storage/storageAccounts'] ?? {}, mlzTags)
var tagsRecoveryServicesVault = union({'cm-resource-parent': hostPoolResourceId}, tags[?'Microsoft.recoveryServices/vaults'] ?? {}, mlzTags)
var tagsVirtualMachines = union({'cm-resource-parent': hostPoolResourceId}, tags[?'Microsoft.Compute/virtualMachines'] ?? {}, mlzTags)

resource storageAccounts 'Microsoft.Storage/storageAccounts@2022-09-01' = [for i in range(0, storageCount): {
name: take('${storageAccountNamePrefix}${padLeft(i + storageIndex, 2, '0')}', 15)
Expand Down Expand Up @@ -206,6 +202,7 @@ resource privateDnsZoneGroups 'Microsoft.Network/privateEndpoints/privateDnsZone
]
}]

// Sets NTFS permissions on the file shares
module ntfsPermissions '../runCommand.bicep' = {
name: 'set-ntfs-permissions-${deploymentNameSuffix}'
scope: resourceGroup(resourceGroupManagement)
Expand Down Expand Up @@ -245,7 +242,7 @@ module ntfsPermissions '../runCommand.bicep' = {
}
{
name: 'StorageAccountResourceGroupName'
value: resourceGroupStorage
value: resourceGroup().name
}
{
name: 'StorageCount'
Expand Down Expand Up @@ -283,6 +280,7 @@ module ntfsPermissions '../runCommand.bicep' = {
]
}

// Deploys backup items for Azure Files
module recoveryServices 'recoveryServices.bicep' = if (enableRecoveryServices) {
name: 'deploy-backup-${deploymentNameSuffix}'
scope: resourceGroup(resourceGroupManagement)
Expand All @@ -291,7 +289,7 @@ module recoveryServices 'recoveryServices.bicep' = if (enableRecoveryServices) {
fileShares: fileShares
location: location
recoveryServicesVaultName: recoveryServicesVaultName
resourceGroupStorage: resourceGroupStorage
resourceGroupStorage: resourceGroup().name
storageAccountNamePrefix: storageAccountNamePrefix
storageCount: storageCount
storageIndex: storageIndex
Expand All @@ -302,22 +300,4 @@ module recoveryServices 'recoveryServices.bicep' = if (enableRecoveryServices) {
]
}

module autoIncreaseStandardFileShareQuota '../../common/function.bicep' = if (fslogixStorageService == 'AzureFiles Premium' && storageCount > 0) {
name: 'deploy-file-share-scaling-${deploymentNameSuffix}'
scope: resourceGroup(resourceGroupManagement)
params: {
files: {
'requirements.psd1': loadTextContent('../../../artifacts/auto-increase-file-share/requirements.psd1')
'run.ps1': loadTextContent('../../../artifacts/auto-increase-file-share/run.ps1')
'../profile.ps1': loadTextContent('../../../artifacts/auto-increase-file-share/profile.ps1')
}
functionAppName: functionAppName
functionName: 'auto-increase-file-share-quota'
schedule: '0 */15 * * * *'
}
dependsOn: [
recoveryServices
]
}

output storageAccountNamePrefix string = storageAccountNamePrefix
Loading

0 comments on commit 34abc08

Please sign in to comment.