From c4eeb9c78259bf7c8f593269d7103cb8de7492ac Mon Sep 17 00:00:00 2001 From: Zachary Cook <58912675+zacdirect@users.noreply.github.com> Date: Mon, 8 Nov 2021 05:45:41 -0600 Subject: [PATCH] Optional passthru of AllowBlobPublicAccess (#4425) --- helpers/GenerateResourcesAndImage.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/helpers/GenerateResourcesAndImage.ps1 b/helpers/GenerateResourcesAndImage.ps1 index 4a4930085..517a983ae 100644 --- a/helpers/GenerateResourcesAndImage.ps1 +++ b/helpers/GenerateResourcesAndImage.ps1 @@ -92,6 +92,9 @@ Function GenerateResourcesAndImage { .PARAMETER RestrictToAgentIpAddress If set, access to the VM used by packer to generate the image is restricted to the public IP address this script is run from. This parameter cannot be used in combination with the virtual_network_name packer parameter. + + .PARAMETER AllowBlobPublicAccess + The Azure storage account will be created with this option. .EXAMPLE GenerateResourcesAndImage -SubscriptionId {YourSubscriptionId} -ResourceGroupName "shsamytest1" -ImageGenerationRepositoryRoot "C:\virtual-environments" -ImageType Ubuntu1804 -AzureLocation "East US" @@ -118,7 +121,9 @@ Function GenerateResourcesAndImage { [Parameter(Mandatory = $False)] [Switch] $RestrictToAgentIpAddress, [Parameter(Mandatory = $False)] - [Switch] $Force + [Switch] $Force, + [Parameter(Mandatory = $False)] + [bool] $AllowBlobPublicAccess = $False, ) $builderScriptPath = Get-PackerTemplatePath -RepositoryRoot $ImageGenerationRepositoryRoot -ImageType $ImageType @@ -186,7 +191,7 @@ Function GenerateResourcesAndImage { $storageAccountName = $storageAccountName.Replace("-", "").Replace("_", "").Replace("(", "").Replace(")", "").ToLower() $storageAccountName += "001" - New-AzStorageAccount -ResourceGroupName $ResourceGroupName -AccountName $storageAccountName -Location $AzureLocation -SkuName "Standard_LRS" + New-AzStorageAccount -ResourceGroupName $ResourceGroupName -AccountName $storageAccountName -Location $AzureLocation -SkuName "Standard_LRS" -AllowBlobPublicAccess $AllowBlobPublicAccess if ([string]::IsNullOrEmpty($AzureClientId)) { # Interactive authentication: A service principal is created during runtime.