From 1ca56197000a4e4f296f3a86d18926acd4cd73ee Mon Sep 17 00:00:00 2001 From: Adam Meltzer Date: Tue, 4 Oct 2022 14:55:39 -0700 Subject: [PATCH 1/2] Fix documentation bugs. Fix duplicate reference. --- README.md | 1 - .../doc/PowerShell/New-WinGetSource.md | 17 +---- .../src/Library/New-ARMParameterObject.ps1 | 63 +++++++++---------- .../src/Library/New-WinGetSource.ps1 | 31 +++++---- .../README.MD | 1 - .../WinGet.RestSource.Utils.csproj | 1 - 6 files changed, 45 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index 975aa8a2..dd13d8b3 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,6 @@ The `New-WinGetSource` PowerShell cmdlet makes use of the following input parame | Required | Parameter | Description | |----------|----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------| | Yes | Name | A string of letters which will be prefixed to your newly created Azure resources. | -| Yes | Index | A string of letters or numbers which will be suffix to your newly created Azure resources. | | Yes | ResourceGroup | The Resource Group that will be used to contain the Azure resources. | | No | SubscriptionName | The name of the Azure Subscription that will be used to pay for the Azure resources. | | No | Region | The Azure location where the Azure resources will be created. (Default: westus) | diff --git a/Tools/PowershellModule/doc/PowerShell/New-WinGetSource.md b/Tools/PowershellModule/doc/PowerShell/New-WinGetSource.md index 4bc6c9c2..2567e2a3 100644 --- a/Tools/PowershellModule/doc/PowerShell/New-WinGetSource.md +++ b/Tools/PowershellModule/doc/PowerShell/New-WinGetSource.md @@ -13,7 +13,7 @@ Creates a Windows Package Manager REST source in Azure for storage of Windows Pa ## SYNTAX ``` -New-WinGetSource [-Name] [[-Index] ] [[-ResourceGroup] ] +New-WinGetSource [-Name] [[-ResourceGroup] ] [[-SubscriptionName] ] [[-Region] ] [[-ParameterOutput] ] [[-RestSourcePath] ] [[-ImplementationPerformance] ] [-ShowConnectionInstructions] [] @@ -62,21 +62,6 @@ Accept pipeline input: False Accept wildcard characters: False ``` -### -Index -\[Optional\] The suffix that will be added to each name and file names. - -```yaml -Type: String -Parameter Sets: (All) -Aliases: - -Required: False -Position: 2 -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - ### -ResourceGroup \[Optional\] The Name of the Resource Group that the Windows Package Manager REST source will reside. All Azure resources will be created in in this Resource Group (Default: WinGetRestSource) (Default: WinGetRestSource) diff --git a/Tools/PowershellModule/src/Library/New-ARMParameterObject.ps1 b/Tools/PowershellModule/src/Library/New-ARMParameterObject.ps1 index 35122f3e..695bfecf 100644 --- a/Tools/PowershellModule/src/Library/New-ARMParameterObject.ps1 +++ b/Tools/PowershellModule/src/Library/New-ARMParameterObject.ps1 @@ -7,8 +7,8 @@ Function New-ARMParameterObject Creates the parameter files, and an object which points to both the created parameter and template files. .DESCRIPTION - Creates a new PowerShell object that contains the Azure Resource type, name, and parameter values. Once created it'll - output the parameter files into a *.json file that can be used in combination with with template files to build Azure + Creates a new PowerShell object that contains the Azure Resource type, name, and parameter values. Once created it'll + output the parameter files into a *.json file that can be used in combination with with template files to build Azure resources required for hosting a Windows Package Manager REST source. Returns the PowerShell object. .PARAMETER ParameterFolderPath @@ -17,9 +17,6 @@ Function New-ARMParameterObject .PARAMETER TemplateFolderPath Path to the directory containing the Template files. - .PARAMETER Index - [Optional] The suffix that will be added to each name and file names. - .PARAMETER Name The name of the objects to be created. @@ -53,11 +50,11 @@ Function New-ARMParameterObject $FunctionName = $Name $FrontDoorName = $Name - ## The names of the Azure Cosmos Database and Container - Do not change (Must match with the values in the compiled + ## The names of the Azure Cosmos Database and Container - Do not change (Must match with the values in the compiled ## Windows Package Manager Functions [WinGet.RestSource.Functions.zip]) $CDBDatabaseName = "WinGet" $CDBContainerName = "Manifests" - + ## Relative Path from the Working Directory to the Azure ARM Template Files $TemplateAppInsightsPath = "$TemplateFolderPath\applicationinsights.json" @@ -91,7 +88,7 @@ Function New-ARMParameterObject ## To enable Serverless then set CosmosDBACapatilities to "[{"name"; ""EnableServerless""}]" $CosmosDBACapabilities = "[]" } - "Basic" { + "Basic" { $KeyVaultSKU = "Standard" $StorageAccountPerformance = "Standard_GRS" $ASPSKU = "S1" @@ -111,10 +108,10 @@ Function New-ARMParameterObject $PrimaryRegionName = $(Get-AzLocation).Where({$_.Location -eq $Region}).DisplayName $SecondaryRegion = Get-PairedAzureRegion -Region $Region $SecondaryRegionName = $(Get-AzLocation).Where({$_.Location -eq $SecondaryRegion}).DisplayName - + ## The name of the Secret that will be created in the Azure Keyvault - Do not change $AzKVStorageSecretName = "AzStorageAccountKey" - + ## This is the Azure Key Vault Key used to store the Connection String to the Storage Account Write-Verbose -Message "Retrieving the Azure Tenant and User Id Information" $AzContext = $(Get-AzContext) @@ -131,97 +128,97 @@ Function New-ARMParameterObject } Write-Verbose -Message "Retrieved the Azure Object Id: $AzObjectID" - + ## This is specific to the JSON file creation $JSONContentVersion = "1.0.0.0" $JSONSchema = "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#" } PROCESS - { - Write-Verbose -Message "Validating that the inputs for the AppInsights template are not null." + { + Write-Verbose -Message "Validating that the inputs for the AppInsights template are not null." if(!($AppInsightsName -and $ParameterAppInsightsPath -and $TemplateAppInsightsPath -and $JSONSchema -and $JSONContentVersion)) { Write-Verbose -Message " Required values are null" Write-Error -Message " Required values are null..." } - else + else { Write-Verbose -Message " inputs are not null." } - Write-Verbose -Message "Validating that the inputs for the Keyvault template are not null." + Write-Verbose -Message "Validating that the inputs for the Keyvault template are not null." if(!($KeyVaultName -and $ParameterKeyVaultPath -and $TemplateAppInsightsPath -and $JSONSchema -and $JSONContentVersion -and $KeyVaultName -and $KeyVaultSKU -and $AzObjectID -and $AzTenantID)) { Write-Verbose -Message " Required values are null" Write-Error -Message " Required values are null..." } - else + else { Write-Verbose -Message " inputs are not null." } - Write-Verbose -Message "Validating that the inputs for the StorageAccount template are not null." + Write-Verbose -Message "Validating that the inputs for the StorageAccount template are not null." if(!($StorageAccountName -and $ParameterStorageAccountPath -and $TemplateStorageAccountPath -and $JSONSchema -and $JSONContentVersion -and $Region -and $StorageAccountName -and $StorageAccountPerformance)) { Write-Verbose -Message " Required values are null" Write-Error -Message " Required values are null..." } - else + else { Write-Verbose -Message " inputs are not null." } - Write-Verbose -Message "Validating that the inputs for the asp template are not null." + Write-Verbose -Message "Validating that the inputs for the asp template are not null." if(!($aspName -and $ParameterASPPath -and $TemplateASPPath -and $JSONSchema -and $JSONContentVersion -and $aspName -and $Region -and $ASPSKU)) { Write-Verbose -Message " Required values are null" Write-Error -Message " Required values are null..." } - else + else { Write-Verbose -Message " inputs are not null." } - Write-Verbose -Message "Validating that the inputs for the CosmosDBAccount template are not null." + Write-Verbose -Message "Validating that the inputs for the CosmosDBAccount template are not null." if(!($CDBAccountName -and $ParameterCDBAccountPath -and $TemplateCDBAccountPath -and $JSONSchema -and $JSONContentVersion -and $CDBAccountName -and $null -ne $CosmosDBAEnableFreeTier -and $PrimaryRegionName -and $SecondaryRegionName)) { Write-Verbose -Message " Required values are null" Write-Error -Message " Required values are null..." } - else + else { Write-Verbose -Message " inputs are not null." } - Write-Verbose -Message "Validating that the inputs for the CosmosDBDatabase template are not null." + Write-Verbose -Message "Validating that the inputs for the CosmosDBDatabase template are not null." if(!($CDBDatabaseName -and $ParameterCDBPath -and $TemplateCDBPath -and $JSONSchema -and $JSONContentVersion -and $CDBAccountName -and $CDBDatabaseName)) { Write-Verbose -Message " Required values are null" Write-Error -Message " Required values are null..." } - else + else { Write-Verbose -Message " inputs are not null." } - Write-Verbose -Message "Validating that the inputs for the CosmosDBContainer template are not null." + Write-Verbose -Message "Validating that the inputs for the CosmosDBContainer template are not null." if(!($CDBContainerName -and $ParameterCDBContainerPath -and $TemplateCDBContainerPath -and $JSONSchema -and $JSONContentVersion -and $CDBAccountName -and $CDBDatabaseName -and $CDBContainerName)) { Write-Verbose -Message " Required values are null" Write-Error -Message " Required values are null..." } - else + else { Write-Verbose -Message " inputs are not null." } - Write-Verbose -Message "Validating that the inputs for the Function template are not null." + Write-Verbose -Message "Validating that the inputs for the Function template are not null." if(!($FunctionName -and $ParameterFunctionPath -and $TemplateFunctionPath -and $JSONSchema -and $JSONContentVersion -and $AzKVStorageSecretName -and $Region -and $CDBDatabaseName -and $CDBContainerName -and $aspName -and $FunctionName -and $KeyVaultName -and $AppInsightsName)) { Write-Verbose -Message " Required values are null" Write-Error -Message " Required values are null..." } - else + else { Write-Verbose -Message " inputs are not null." } @@ -250,7 +247,7 @@ Function New-ARMParameterObject '$Schema' = $JSONSchema contentVersion = $JSONContentVersion Parameters = @{ - name = @{ + name = @{ value = $KeyVaultName type = "string" } @@ -313,11 +310,11 @@ Function New-ARMParameterObject Parameters = @{ name = @{ value = $CDBAccountName } enableFreeTier = @{ value = $CosmosDBAEnableFreeTier } - tags = @{ + tags = @{ value = @{ defaultExperience = "Core (SQL)" CosmosAccountType = "Production" - } + } } consistencyPolicy = @{ value = @{ @@ -459,7 +456,7 @@ Function New-ARMParameterObject # ObjectName = $FrontDoorName # ParameterPath = "$ParameterFrontDoorPath" # TemplatePath = "$TemplateFrontDoorPath" - # Error = "" + # Error = "" # Parameters = @{ # '$Schema' = $JSONSchema # contentVersion = $JSONContentVersion @@ -539,7 +536,7 @@ Function New-ARMParameterObject # forwardingProtocol = "HttpsOnly" # backendPoolName = "api" # } - # } + # } # ) # } # backendPoolsSettings = @{ diff --git a/Tools/PowershellModule/src/Library/New-WinGetSource.ps1 b/Tools/PowershellModule/src/Library/New-WinGetSource.ps1 index 932e608b..75913c40 100644 --- a/Tools/PowershellModule/src/Library/New-WinGetSource.ps1 +++ b/Tools/PowershellModule/src/Library/New-WinGetSource.ps1 @@ -18,11 +18,8 @@ Function New-WinGetSource .PARAMETER Name The name of the objects that will be created - .PARAMETER Index - [Optional] The suffix that will be added to each name and file names. - .PARAMETER ResourceGroup - [Optional] The name of the Resource Group that the Windows Package Manager REST source will reside. All Azure + [Optional] The name of the Resource Group that the Windows Package Manager REST source will reside. All Azure resources will be created in in this Resource Group (Default: WinGetRestsource) .PARAMETER SubscriptionName @@ -44,7 +41,7 @@ Function New-WinGetSource | Demo | Specifies lowest cost for demonstrating the Windows Package Manager REST source. Uses free-tier options when available. | | Basic | Specifies a basic functioning Windows Package Manager REST source. | | Enhanced | Specifies a higher tier functionality with data replication across multiple data centers. | - + (Default: Basic) .PARAMETER ShowConnectionInstructions @@ -53,14 +50,14 @@ Function New-WinGetSource .EXAMPLE New-WinGetSource -Name "contosorestsource" - Creates the Windows Package Manager REST source in Azure with resources named "contosorestsource" in the westus region of + Creates the Windows Package Manager REST source in Azure with resources named "contosorestsource" in the westus region of Azure with the basic level performance. .EXAMPLE New-WinGetSource -Name "contosorestsource" -ResourceGroup "WinGet" -SubscriptionName "Visual Studio Subscription" -Region "westus" -ParameterOutput "C:\WinGet" -ImplementationPerformance "Basic" -ShowConnectionInformation - Creates the Windows Package Manager REST source in Azure with resources named "contosorestsource" in the westus region of - Azure with the basic level performance in the "Visual Studio Subscription" Subscription. Displays the required command + Creates the Windows Package Manager REST source in Azure with resources named "contosorestsource" in the westus region of + Azure with the basic level performance in the "Visual Studio Subscription" Subscription. Displays the required command to connect the WinGet client to the new REST source after the REST source has been created. #> @@ -81,11 +78,11 @@ Function New-WinGetSource $WarningMessage = "`n The ""Demo"" build creates the Azure Cosmos DB Account with the ""Free-tier"" option selected which offset the total cost. Only 1 Cosmos DB Account per tenant can make use of this.`n`n" Write-Warning -Message $WarningMessage } - + ## Paths to the Parameter and Template folders and the location of the Function Zip $ParameterFolderPath = "$ParameterOutput\Parameters" $TemplateFolderPath = "$PSScriptRoot\ARMTemplate" - + ## Outlines the Azure Modules that are required for this Function to work. $RequiredModules = @("Az.Resources", "Az.Accounts", "Az.KeyVault","Az.Websites", "Az.Functions") } @@ -106,14 +103,14 @@ Function New-WinGetSource ## Create Folders for the Parameter folder paths $ResultParameter = New-Item -ItemType Directory -Path $ParameterFolderPath -ErrorAction SilentlyContinue -InformationAction SilentlyContinue - if($ResultParameter) { - Write-Verbose -Message "Created Directory to contain the ARM Parameter files ($($ResultParameter.FullName))." + if($ResultParameter) { + Write-Verbose -Message "Created Directory to contain the ARM Parameter files ($($ResultParameter.FullName))." } - + ############################### ## Connects to Azure, if not already connected. Write-Verbose -Message "Testing connection to Azure." - + $Result = Connect-ToAzure -SubscriptionName $SubscriptionName if(!($Result)) { throw "Failed to connect to Azure. Please run Connect-AzAccount to connect to Azure, or re-run the cmdlet and enter your credentials." @@ -124,10 +121,10 @@ Function New-WinGetSource $ARMObjects = New-ARMParameterObject -ParameterFolderPath $ParameterFolderPath -TemplateFolderPath $TemplateFolderPath -Name $Name -Region $Region -ImplementationPerformance $ImplementationPerformance ############################### - ## Create Resource Group + ## Create Resource Group Write-Verbose -Message "Creating the Resource Group used to host the Windows Package Manager REST source." Add-AzureResourceGroup -Name $ResourceGroup -Region $Region - + #### Verifies ARM Parameters are correct #### $Result = Test-ARMTemplate -ARMObjects $ARMObjects -ResourceGroup $ResourceGroup -ErrorAction SilentlyContinue -ErrorVariable err @@ -137,7 +134,7 @@ Function New-WinGetSource ResourceGroup = $ResourceGroup Result = $Result } - + Write-Error -Message "Testing found an error with the ARM template or parameter files." -TargetObject $ErrReturnObject } diff --git a/src/WinGet.RestSource.Infrastructure/README.MD b/src/WinGet.RestSource.Infrastructure/README.MD index 45b3d5f8..33496a03 100644 --- a/src/WinGet.RestSource.Infrastructure/README.MD +++ b/src/WinGet.RestSource.Infrastructure/README.MD @@ -12,7 +12,6 @@ The `New-WinGetSource` PowerShell cmdlet makes use of the following input parame | Required | Parameter | Description | |----------|----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------| | Yes | Name | A string of letters which will be prefixed to your newly created Azure resources. | -| Yes | Index | A string of letters or numbers which will be suffix to your newly created Azure resources. | | Yes | ResourceGroup | The Resource Group that will be used to contain the Azure resources. | | No | SubscriptionName | The name of the Azure Subscription that will be used to pay for the Azure resources. | | No | Region | The Azure location where the Azure resources will be created. (Default: westus) | diff --git a/src/WinGet.RestSource.Utils/WinGet.RestSource.Utils.csproj b/src/WinGet.RestSource.Utils/WinGet.RestSource.Utils.csproj index 76d2ff6b..fbea85d9 100644 --- a/src/WinGet.RestSource.Utils/WinGet.RestSource.Utils.csproj +++ b/src/WinGet.RestSource.Utils/WinGet.RestSource.Utils.csproj @@ -44,7 +44,6 @@ - From 23e07fcb92e83efd8e1f498beb216a25d0d3e6cd Mon Sep 17 00:00:00 2001 From: Adam Meltzer Date: Tue, 4 Oct 2022 15:25:52 -0700 Subject: [PATCH 2/2] address comment --- src/WinGet.RestSource.Utils/WinGet.RestSource.Utils.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WinGet.RestSource.Utils/WinGet.RestSource.Utils.csproj b/src/WinGet.RestSource.Utils/WinGet.RestSource.Utils.csproj index fbea85d9..8f2eb2a3 100644 --- a/src/WinGet.RestSource.Utils/WinGet.RestSource.Utils.csproj +++ b/src/WinGet.RestSource.Utils/WinGet.RestSource.Utils.csproj @@ -42,7 +42,7 @@ - +