Skip to content

Commit

Permalink
New arm parameters azure feature (#199)
Browse files Browse the repository at this point in the history
* Update New-ARMParameterObject.ps1

Created space for the new ARM Parameters to be populated.

* Inclusion of the HelperLib folder

* Updated GitIgnore

Removed the commented out code for FrontDoor Parameter file.

Commented out the code for ASP
Created new variables for the ASP_Geneva Template + Parameter files
Created new variables for the AppConfig Template + Parameter files

* Updated ARM Parameter and ASP

Included the ASP Template
Updated to include new AppConfig Parameter file + ASPGeneva

* Update New-ARMParameterObject.ps1

Commented out Geneva and enabled AppConfig
Re-enabled ASP

* Update New-ARMParameterObject.ps1

Re-order the requesting

* Update

Updated the GitIgnore to include testing files.
Added testing for REST Function Config

* Removed HelperLib

* Update .gitignore

Updated Git Ignore

* Update copy-and-publish-powershell.yml

Updated build pipeline to include all json files in PowerShell artifact

* Update copy-and-publish-powershell.yml

Zach told me to do this.

* Fixed New-WinGetSource cmdlet

* Enhanced the Verbose logging.
* Corrected the New-WinGet Source cmdlet

* Update New-WinGetSource.ps1

Updated Verbose logging.

* Update WinGet.RestSource.PowershellSupport.csproj

Added Nuget to the PowerShell Support CSProj

* Update

* Update WinGet.RestSource.Utils.csproj

* Update WinGet.RestSource.Functions.csproj

* Fixed minor issues.

* Fetching upstream content changes

* Update New-ARMObjects.ps1

* Update .gitignore

* Delete Tools/PowershellModule/src/Library/ARMTemplate directory

* Delete Tools/PowershellModule/src/Library/RestAPI directory

* Delete Tools/PowershellModule/src/Library/WinGet.RestSource.PowershellSupport directory

* Update Microsoft.WinGet.Source.psd1

* Update New-ARMObjects.ps1

* Resolved Git Comments
  • Loading branch information
RDMacLachlan authored Sep 6, 2023
1 parent 00755b4 commit af2275e
Show file tree
Hide file tree
Showing 13 changed files with 159 additions and 139 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ bld/
[Ll]og/
[Ll]ogs/

# These are the PowerShell helper libraries used to run. Added to artifact as automated task
Tools/PowershellModule/src/Library/ARMTemplate
Tools/PowershellModule/src/Library/RestAPI
Tools/PowershellModule/src/Library/WinGet.RestSource.PowerShellSupport

# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
Expand Down
1 change: 1 addition & 0 deletions Tools/PowershellModule/src/Library/Add-WinGetManifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ Function Add-WinGetManifest
Write-Verbose -Message "Retrieving a copy of the app Manifest file for submission to WinGet source."
$ApplicationManifest = Get-WinGetManifest -Path $Path
if(!$ApplicationManifest) {
Write-Verbose "$ApplicationManifest`n`n`n"
throw "Failed to retrieve a proper manifest. Verify and try again."
}

Expand Down
10 changes: 9 additions & 1 deletion Tools/PowershellModule/src/Library/Get-WinGetManifest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,18 @@ Function Get-WinGetManifest
if($WinGetDesktopAppInstallerLibLoaded) {
Write-Verbose -Message "YAML Files have been found in the target directory. Building a JSON manifest with found files."
if($Json){
Write-Verbose "JSON"
$Return += [Microsoft.WinGet.RestSource.PowershellSupport.YamlToRestConverter]::AddManifestToPackageManifest($Path, $JSON.GetJson());
}
else{
$Return += [Microsoft.WinGet.RestSource.PowershellSupport.YamlToRestConverter]::AddManifestToPackageManifest($Path, "");
Write-Verbose "Other"
try {
$Return += [Microsoft.WinGet.RestSource.PowershellSupport.YamlToRestConverter]::AddManifestToPackageManifest($Path, "");
}
catch {
Write-Verbose "Attempt to convert YAML to JSON failed."
}

}

Write-Verbose -Message "Returned Manifest from YAML file: $($Return.PackageIdentifier)"
Expand Down
5 changes: 5 additions & 0 deletions Tools/PowershellModule/src/Library/New-ARMObjects.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ Function New-ARMObjects
## Sets a sleep of 10 seconds after object creation to allow Azure to update creation status, and mark as "running"
Start-Sleep -Seconds 10
}

## Sets an additional sleep of 10 seconds, to account for delays in availability
Start-Sleep -Seconds 10

## Verifies that no error occured when creating the Azure resource
if($objerror -or $Result.Error) {
Expand All @@ -143,6 +146,8 @@ Function New-ARMObjects
## Verifies the presence of the "WinGet.RestSource.Functions.zip" file.
Write-Verbose -Message " Confirming Compiled Azure Functions is present"
if(Test-Path $RestSourcePath) {
Start-Sleep -Seconds 10

## The "WinGet.RestSource.Functions.zip" was found in the working directory
Write-Verbose -Message " File Path Found: $RestSourcePath"

Expand Down
168 changes: 50 additions & 118 deletions Tools/PowershellModule/src/Library/New-ARMParameterObject.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,22 @@ Function New-ARMParameterObject
$CDBAccountName = $Name
$FunctionName = $Name
$FrontDoorName = $Name
$appConfigName = $Name
$aspGenevaName = $Name

## 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"

## The values required for Function ARM Template
$manifestCacheEndpoint = ""
$monitoringTenant = ""
$monitoringRole = ""
$monitoringMetricsAccount = ""

## The values required for the Azure App Config ARM Template
#$appConfigFeatureFlag = ""

## Relative Path from the Working Directory to the Azure ARM Template Files
$TemplateAppInsightsPath = "$TemplateFolderPath\applicationinsights.json"
Expand All @@ -66,16 +76,18 @@ Function New-ARMParameterObject
$TemplateCDBContainerPath = "$TemplateFolderPath\cosmosdb-sql-container.json"
$TemplateFunctionPath = "$TemplateFolderPath\azurefunction.json"
$TemplateFrontDoorPath = "$TemplateFolderPath\frontdoor.json"
$TemplateAppConfigPath = "$TemplateFolderPath\appconfig.json"

$ParameterAppInsightsPath = "$ParameterFolderPath\applicationinsights$NameEntryIndex.json"
$ParameterKeyVaultPath = "$ParameterFolderPath\keyvault$NameEntryIndex.json"
$ParameterStorageAccountPath = "$ParameterFolderPath\storageaccount$NameEntryIndex.json"
$ParameterASPPath = "$ParameterFolderPath\asp$NameEntryIndex.json"
$ParameterCDBAccountPath = "$ParameterFolderPath\cosmosdb$NameEntryIndex.json"
$ParameterCDBPath = "$ParameterFolderPath\cosmosdb-sql$NameEntryIndex.json"
$ParameterCDBContainerPath = "$ParameterFolderPath\cosmosdb-sql-container$NameEntryIndex.json"
$ParameterFunctionPath = "$ParameterFolderPath\azurefunction$NameEntryIndex.json"
$ParameterFrontDoorPath = "$ParameterFolderPath\frontdoor$NameEntryIndex.json"
$ParameterAppInsightsPath = "$ParameterFolderPath\applicationinsights.json"
$ParameterKeyVaultPath = "$ParameterFolderPath\keyvault.json"
$ParameterStorageAccountPath = "$ParameterFolderPath\storageaccount.json"
$ParameterASPPath = "$ParameterFolderPath\asp.json"
$ParameterCDBAccountPath = "$ParameterFolderPath\cosmosdb.json"
$ParameterCDBPath = "$ParameterFolderPath\cosmosdb-sql.json"
$ParameterCDBContainerPath = "$ParameterFolderPath\cosmosdb-sql-container.json"
$ParameterFunctionPath = "$ParameterFolderPath\azurefunction.json"
$ParameterFrontDoorPath = "$ParameterFolderPath\frontdoor.json"
$ParameterAppConfigPath = "$ParameterFolderPath\appconfig.json"

Write-Verbose -Message "ARM Parameter Resource performance is based on the: $ImplementationPerformance."

Expand Down Expand Up @@ -268,6 +280,21 @@ Function New-ARMParameterObject
}
}
},
@{ ObjectType = "AppConfig"
ObjectName = $FunctionName
ParameterPath = "$ParameterAppConfigPath"
TemplatePath = "$TemplateAppConfigPath"
Error = ""
Parameters = @{
'$Schema' = $JSONSchema
contentVersion = $JSONContentVersion
Parameters = @{
appConfigName = @{ value = $appConfigName } # Name used to contain the Storage Account connection string in the Key Value
location = @{ value = $Region } # Azure hosting location
#featureFlags = @{ value = $appConfigFeatureFlag } # Feature Flag
}
}
},
@{ ObjectType = "StorageAccount"
ObjectName = $StorageAccountName
ParameterPath = "$ParameterStorageAccountPath"
Expand Down Expand Up @@ -440,117 +467,22 @@ Function New-ARMParameterObject
'$Schema' = $JSONSchema
contentVersion = $JSONContentVersion
Parameters = @{
storageSecretName = @{ value = $AzKVStorageSecretName } # Name used to contain the Storage Account connection string in the Key Value
location = @{ value = $Region } # Azure hosting location
cosmosDatabase = @{ value = $CDBDatabaseName } # Cosmos Database Name
cosmosContainer = @{ value = $CDBContainerName } # Cosmos Container Name
serverIdentifier = @{ value = $aspName } # Azure Function Name
functionName = @{ value = $FunctionName } # Azure Function Name
appServiceName = @{ value = $aspName } # Azure App Service Name
keyVaultName = @{ value = $KeyVaultName } # Azure Keyvault Name
appInsightName = @{ value = $AppInsightsName } # Azure App Insights Name
storageSecretName = @{ value = $AzKVStorageSecretName } # Name used to contain the Storage Account connection string in the Key Value
location = @{ value = $Region } # Azure hosting location
cosmosDatabase = @{ value = $CDBDatabaseName } # Cosmos Database Name
cosmosContainer = @{ value = $CDBContainerName } # Cosmos Container Name
serverIdentifier = @{ value = $aspName } # Azure Function Name
functionName = @{ value = $FunctionName } # Azure Function Name
appServiceName = @{ value = $aspName } # Azure App Service Name
keyVaultName = @{ value = $KeyVaultName } # Azure Keyvault Name
appInsightName = @{ value = $AppInsightsName } # Azure App Insights Name
manifestCacheEndpoint = @{ value = $manifestCacheEndpoint } # unknown
monitoringTenant = @{ value = $monitoringTenant } # unknown
monitoringRole = @{ value = $monitoringRole } # unknown
monitoringMetricsAccount = @{ value = $monitoringMetricsAccount } # unknown
}
}
}#,
# @{ ObjectType = "FrontDoor" ## Requires a CName entry be created for the frontend endpoint.
# ObjectName = $FrontDoorName
# ParameterPath = "$ParameterFrontDoorPath"
# TemplatePath = "$TemplateFrontDoorPath"
# Error = ""
# Parameters = @{
# '$Schema' = $JSONSchema
# contentVersion = $JSONContentVersion
# Parameters = @{
# name = @{ value = $FrontDoorName }
# frontendEndpoints = @{
# value = @(
# @{
# name = "$($Name + "azurefd")"
# properties = @{
# hostName = "$($Name + "azurefd").azurefd.net"
# sessionAffinityEnabledState = "Disabled"
# sessionAffinityTtlSeconds = 0
# resourceState = "Enabled"
# }
# }
# )
# }
# healthProbeSettings = @{
# value = @(
# @{
# name = "healthProbe-fiveSecond"
# properties = @{
# intervalInSeconds = 5
# path = "/"
# protocol = "Https"
# resourceState = "Enabled"
# enabledState = "Enabled"
# healthProbeMethod = "Head"
# }
# }
# )
# }
# loadBalancingSettings = @{
# value = @(
# @{
# name = "loadBalancing-tenSample"
# properties = @{
# additionalLatencyMilliseconds = 1000
# sampleSize = 10
# successfulSamplesRequired = 5
# resourceState = "Enabled"
# }
# }
# )
# }
# backendPools = @{
# value = @(
# @{
# name = "api"
# backEnds = @(
# @{
# address = "$FunctionName.azurewebsites.net"
# httpPort = 80
# httpsPort = 443
# priority = 1
# weight = 50
# backendHostHeader = "$FunctionName.azurewebsites.net"
# enabledState = "Enabled"
# }
# )
# HealthProbeSettingsName = "healthProbe-fiveSecond"
# loadBalancingSettingsName = "loadBalancing-tenSample"
# }
# )
# }
# routingRules = @{
# value = @(
# @{
# name = "api-rule"
# frontendEndpoint = "$($Name + "azurefd")"
# acceptedProtocols = @( "Https" )
# patternsToMatch = @( "/api/*" )
# enabledState = "Enabled"
# routeConfiguration = @{
# odataType = "#Microsoft.Azure.FrontDoor.Models.FrontdoorForwardingConfiguration"
# forwardingProtocol = "HttpsOnly"
# backendPoolName = "api"
# }
# }
# )
# }
# backendPoolsSettings = @{
# value = @{
# enforceCertificateNameCheck = "Enabled"
# sendRecvTimeoutSeconds = 30
# }
# }
# enabledState = @{
# value = "Enabled"
# }
# }
# }
# }
}
)

## Uses the newly created ARMObjects[#].Parameters to create new JSON Parameter files.
Expand Down
10 changes: 9 additions & 1 deletion Tools/PowershellModule/src/Library/New-WinGetSource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,17 @@ Function New-WinGetSource
## Validates that the Azure Modules are installed
Write-Verbose -Message "Testing required PowerShell modules are installed."

$RequiredModules = @("Az.Resources", "Az.Accounts", "Az.Websites", "Az.Functions")
$RequiredModules = @("Az.Resources", "Az.Accounts", "Az.Websites", "Az.Functions", "Az.Storage")
$Result = Test-PowerShellModuleExist -Modules $RequiredModules

if(!$Result) {
throw "Unable to run script, missing required PowerShell modules"
}
if(!$(Test-Path -Path $RestSourcePath))
{
throw "REST Source Function Code is missing in specified path ($RestSourcePath)"
}


###############################
## Create Folders for the Parameter folder paths
Expand Down Expand Up @@ -136,6 +141,7 @@ Function New-WinGetSource
}

Write-Error -Message "Testing found an error with the ARM template or parameter files." -TargetObject $ErrReturnObject
Write-Host $Err[0]
}


Expand Down Expand Up @@ -164,6 +170,8 @@ Function New-WinGetSource
#### Instructions on how to add the REST source to your Windows Package Manager Client
Write-Information -MessageData "Use the following command to register the new REST source with your Windows Package Manager Client:"
Write-Information -MessageData " winget source add -n ""restsource"" -a ""https://$AzFunctionURL/api/"" -t ""Microsoft.Rest"""
Write-Verbose -Message "Use the following command to register the new REST source with your Windows Package Manager Client:"
Write-Verbose -Message " winget source add -n ""restsource"" -a ""https://$AzFunctionURL/api/"" -t ""Microsoft.Rest"""

#### For more information about how to use the solution, visit the aka.ms link.
Write-Information -MessageData "`n For more information on the Windows Package Manager Client, go to: https://aka.ms/winget-command-help`n"
Expand Down
Loading

0 comments on commit af2275e

Please sign in to comment.