Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
17 changes: 1 addition & 16 deletions Tools/PowershellModule/doc/PowerShell/New-WinGetSource.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Creates a Windows Package Manager REST source in Azure for storage of Windows Pa
## SYNTAX

```
New-WinGetSource [-Name] <String> [[-Index] <String>] [[-ResourceGroup] <String>]
New-WinGetSource [-Name] <String> [[-ResourceGroup] <String>]
[[-SubscriptionName] <String>] [[-Region] <String>] [[-ParameterOutput] <String>]
[[-RestSourcePath] <String>] [[-ImplementationPerformance] <String>] [-ShowConnectionInstructions]
[<CommonParameters>]
Expand Down Expand Up @@ -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)
Expand Down
63 changes: 30 additions & 33 deletions Tools/PowershellModule/src/Library/New-ARMParameterObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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)
Expand All @@ -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."
}
Expand Down Expand Up @@ -250,7 +247,7 @@ Function New-ARMParameterObject
'$Schema' = $JSONSchema
contentVersion = $JSONContentVersion
Parameters = @{
name = @{
name = @{
value = $KeyVaultName
type = "string"
}
Expand Down Expand Up @@ -313,11 +310,11 @@ Function New-ARMParameterObject
Parameters = @{
name = @{ value = $CDBAccountName }
enableFreeTier = @{ value = $CosmosDBAEnableFreeTier }
tags = @{
tags = @{
value = @{
defaultExperience = "Core (SQL)"
CosmosAccountType = "Production"
}
}
}
consistencyPolicy = @{
value = @{
Expand Down Expand Up @@ -459,7 +456,7 @@ Function New-ARMParameterObject
# ObjectName = $FrontDoorName
# ParameterPath = "$ParameterFrontDoorPath"
# TemplatePath = "$TemplateFrontDoorPath"
# Error = ""
# Error = ""
# Parameters = @{
# '$Schema' = $JSONSchema
# contentVersion = $JSONContentVersion
Expand Down Expand Up @@ -539,7 +536,7 @@ Function New-ARMParameterObject
# forwardingProtocol = "HttpsOnly"
# backendPoolName = "api"
# }
# }
# }
# )
# }
# backendPoolsSettings = @{
Expand Down
31 changes: 14 additions & 17 deletions Tools/PowershellModule/src/Library/New-WinGetSource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.

#>
Expand All @@ -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")
}
Expand All @@ -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."
Expand All @@ -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

Expand All @@ -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
}

Expand Down
1 change: 0 additions & 1 deletion src/WinGet.RestSource.Infrastructure/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
3 changes: 1 addition & 2 deletions src/WinGet.RestSource.Utils/WinGet.RestSource.Utils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.22.0" />
<PackageReference Include="Microsoft.WindowsPackageManager.Utils" Version="0.3.4" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.12" />
<PackageReference Include="Microsoft.WindowsPackageManager.Utils" Version="*" />
Comment thread
This conversation was marked as resolved.
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.12" />
</ItemGroup>

<!-- Component Governance fix Item Group. -->
Expand Down