-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Task]14569737: add throttle cdn config (#1906)
* add throttle cdn config * update throttle cdn config * remove aisku throttle cdn scripts * remove throtle json from aisku * update throttle config cdn file name * update scripts * change throttle config to config * disable default config Co-authored-by: Nev <54870357+MSNev@users.noreply.github.com>
- Loading branch information
1 parent
9dc437b
commit d929ac8
Showing
9 changed files
with
502 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
{ | ||
"name":"Application Insights Config", | ||
"description":" Application Insights JavaScript SDK - Web Config", | ||
"copyright": "(c) Microsoft and contributors. All rights reserved.", | ||
"author": "Microsoft Application Insights Team", | ||
"throttleConfig": { | ||
"default": { | ||
"msgKey": 0, | ||
"limit": { | ||
"sendPercentage": 0, | ||
"maxSendNumber": 0 | ||
}, | ||
"interval": { | ||
"monthInterval": 100, | ||
"dayInterval": 100, | ||
"maxTimesPerMonth": 0 | ||
} | ||
}, | ||
"config": { | ||
"ikeyDeprecation": { | ||
"msgKey": 1, | ||
"limit": { | ||
"sendPercentage": 1, | ||
"maxSendNumber": 10 | ||
}, | ||
"interval": { | ||
"monthInterval": 3, | ||
"dayInterval": 28, | ||
"maxTimesPerMonth": 1 | ||
} | ||
}, | ||
"cdnDeprecation": { | ||
"ikeyDeprecation": { | ||
"msgKey": 2, | ||
"limit": { | ||
"sendPercentage": 1, | ||
"maxSendNumber": 10 | ||
}, | ||
"interval": { | ||
"monthInterval": 3, | ||
"dayInterval": 28, | ||
"maxTimesPerMonth": 1 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "applicationinsights-web-config", | ||
"description":" Application Insights JavaScript SDK - Web Config", | ||
"version": "0.0.0", | ||
"copyright": "(c) Microsoft and contributors. All rights reserved.", | ||
"author": "Microsoft Application Insights Team", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/microsoft/ApplicationInsights-JS.git" | ||
}, | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/microsoft/ApplicationInsights-JS/issues" | ||
}, | ||
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
param ( | ||
[string] $container = $null, # Identify the container that you want to check blank == all | ||
[string] $storeContainer = "cdn", # Identifies the destination storage account container | ||
[string] $cdnStorePath = "cdnstoragename", # Identifies the target Azure Storage account (by name) | ||
[string] $subscriptionId = $null, # Identifies the target Azure Subscription Id (if not encoded in the cdnStorePath) | ||
[string] $resourceGroup = $null, # Identifies the target Azure Subscription Resource Group (if not encoded in the cdnStorePath) | ||
[string] $sasToken = $null, # The SAS Token to use rather than using or attempting to login | ||
[string] $logPath = $null, # The location where logs should be written | ||
[switch] $showFiles = $false, # Show the individual files with details as well | ||
[switch] $activeOnly = $false, # Only show the active (deployed) versions | ||
[switch] $testOnly = $false, # Uploads to a "tst" test container on the storage account | ||
[switch] $cdn = $false # (No longer used -- kept for now for backward compatibility) | ||
) | ||
|
||
Import-Module -Force -Name "../../../common/publish/Logging" | ||
Import-Module -Force -Name "../../../common/publish/AzureStorageHelper" | ||
|
||
[hashtable]$global:connectDetails = @{} | ||
$global:connectDetails.storeContainer = $storeContainer | ||
$global:connectDetails.cdnStorePath = $cdnStorePath | ||
$global:connectDetails.resourceGroup = $resourceGroup | ||
$global:connectDetails.storeName = $null # The endpoint needs to the base name of the endpoint, not the full URL (eg. “my-cdn” rather than “my-cdn.azureedge.net”) | ||
$global:connectDetails.subscriptionId = $subscriptionId | ||
$global:connectDetails.sasToken = $sasToken | ||
$global:connectDetails.storageContext = $null | ||
$global:connectDetails.testOnly = $testOnly | ||
|
||
Function Write-LogParams | ||
{ | ||
$logDir = Get-LogPath | ||
|
||
Write-Log "Container : $container" | ||
Write-Log "Storage Container : $storeContainer" | ||
Write-Log "Store Path : $($global:connectDetails.cdnStorePath)" | ||
Write-Log "Log Path : $logDir" | ||
Write-Log "Show Files : $showFiles" | ||
Write-Log "Test Mode : $testOnly" | ||
|
||
if ([string]::IsNullOrWhiteSpace($global:connectDetails.sasToken) -eq $true) { | ||
Write-Log "Mode : User-Credentials" | ||
} else { | ||
Write-Log "Mode : Sas-Token" | ||
} | ||
} | ||
|
||
Function Validate-Params | ||
{ | ||
# Validate parameters | ||
if ([string]::IsNullOrWhiteSpace($container) -ne $true -and "beta","next","public", "dev", "nightly" -NotContains $container) { | ||
Write-LogFailure "[$($container)] is not a valid value, must be beta, next or public" | ||
} | ||
} | ||
|
||
Function Get-AllVersionFiles( | ||
[system.collections.generic.dictionary[string, system.collections.generic.list[hashtable]]] $files, | ||
[string] $storagePath | ||
) { | ||
Get-VersionFiles $files "$storagePath" "ai.config." $null | ||
} | ||
|
||
$Error.Clear() | ||
|
||
#----------------------------------------------------------------------------- | ||
# Start of Script | ||
#----------------------------------------------------------------------------- | ||
Set-LogPath $logPath, "listCdnVersionsLog" | ||
Write-LogParams | ||
Validate-Params | ||
|
||
# Don't try and list anything if any errors have been logged | ||
if (Get-HasErrors -eq $true) { | ||
exit 2 | ||
} | ||
|
||
# You will need to at least have the AzureRM module installed | ||
InstallRequiredModules | ||
$global:connectDetails = ParseCdnStorePath $global:connectDetails | ||
|
||
if ([string]::IsNullOrWhiteSpace($global:connectDetails.sasToken) -eq $true) { | ||
Write-Log "**********************************************************************" | ||
Write-Log "Validating user access" | ||
Write-Log "**********************************************************************" | ||
$global:connectDetails = ValidateAccess $global:connectDetails | ||
} | ||
|
||
Write-Log "======================================================================" | ||
# List the files for each container | ||
$files = New-Object 'system.collections.generic.dictionary[string, system.collections.generic.list[hashtable]]' | ||
|
||
|
||
# Get the public files (scripts/b) | ||
if ([string]::IsNullOrWhiteSpace($container) -eq $true) { | ||
Get-AllVersionFiles $files "scripts/b" | ||
Get-AllVersionFiles $files "beta" | ||
Get-AllVersionFiles $files "next" | ||
Get-AllVersionFiles $files "dev" | ||
Get-AllVersionFiles $files "nightly" | ||
} | ||
|
||
if ([string]::IsNullOrWhiteSpace($container) -ne $true) { | ||
if ($container -eq "public") { | ||
Get-AllVersionFiles $files "scripts/b" | ||
} elseif ($container -eq "beta" -or $container -eq "next" -or $container -eq "dev" -or $container -eq "nightly") { | ||
Get-AllVersionFiles $files "$container" | ||
} else { | ||
$global:connectDetails.testOnly = $true | ||
$global:connectDetails.storeContainer = "tst" | ||
Get-AllVersionFiles $files "$container" | ||
} | ||
} | ||
|
||
ListVersions $files $activeOnly $showFiles | ||
|
||
Write-Log "======================================================================" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
param ( | ||
[string] $releaseFrom = $null, # The root path for where to find the files to be released | ||
[string] $storeContainer = "cdn", # Identifies the destination storage account container | ||
[string] $cdnStorePath = "cdnstoragename", # Identifies the target Azure Storage account (by name) | ||
[string] $subscriptionId = $null, # Identifies the target Azure Subscription Id (if not encoded in the cdnStorePath) | ||
[string] $resourceGroup = $null, # Identifies the target Azure Subscription Resource Group (if not encoded in the cdnStorePath) | ||
[string] $sasToken = $null, # The SAS Token to use rather than using or attempting to login | ||
[string] $logPath = $null, # The location where logs should be written | ||
[switch] $overwrite = $false, # Overwrite any existing files | ||
[switch] $testOnly = $false, # Uploads to a "tst" test container on the storage account | ||
[switch] $cdn = $false # (No longer used -- kept for now for backward compatibility) | ||
) | ||
|
||
Import-Module -Force -Name "../../../common/publish/Logging" | ||
Import-Module -Force -Name "../../../common/publish/AzureStorageHelper" | ||
|
||
[hashtable]$global:connectDetails = @{} | ||
$global:connectDetails.storeContainer = $storeContainer | ||
$global:connectDetails.cdnStorePath = $cdnStorePath | ||
$global:connectDetails.resourceGroup = $resourceGroup | ||
$global:connectDetails.storeName = $null # The endpoint needs to the base name of the endpoint, not the full URL (eg. “my-cdn” rather than “my-cdn.azureedge.net”) | ||
$global:connectDetails.subscriptionId = $subscriptionId | ||
$global:connectDetails.sasToken = $sasToken | ||
$global:connectDetails.storageContext = $null | ||
$global:connectDetails.testOnly = $testOnly | ||
|
||
$global:cacheValue = $null | ||
|
||
Function Write-LogParams | ||
{ | ||
$logDir = Get-LogPath | ||
|
||
Write-Log "Storage Container : $storeContainer" | ||
Write-Log "Store Path : $($global:connectDetails.cdnStorePath)" | ||
Write-Log "Overwrite : $overwrite" | ||
Write-Log "Test Mode : $testOnly" | ||
Write-Log "SourcePath : $jsSdkDir" | ||
Write-Log "Log Path : $logDir" | ||
|
||
if ([string]::IsNullOrWhiteSpace($global:connectDetails.sasToken) -eq $true) { | ||
Write-Log "Mode : User-Credentials" | ||
} else { | ||
Write-Log "Mode : Sas-Token" | ||
} | ||
} | ||
|
||
Function GetReleaseFiles ( | ||
[hashtable] $verDetails | ||
) | ||
{ | ||
$version = $verDetails.full | ||
Write-Log "Version : $($verDetails.full)" | ||
Write-Log " Number : $($verDetails.ver)" | ||
Write-Log " Type : $($verDetails.type)" | ||
Write-Log " BldNum : $($verDetails.bldNum)" | ||
|
||
# check if the minified dir exists | ||
$jsSdkSrcDir = Join-Path $jssdkDir -ChildPath "browser\"; | ||
|
||
if (-Not (Test-Path $jsSdkSrcDir)) { | ||
Write-LogWarning "'$jsSdkSrcDir' directory doesn't exist. Compile JSSDK first."; | ||
exit | ||
} | ||
|
||
$files = New-Object 'system.collections.generic.dictionary[string,string]' | ||
|
||
Write-Log "Adding files"; | ||
AddReleaseFile $files $jsSdkSrcDir "ai.config.$version.cfg.json" | ||
return $files | ||
} | ||
|
||
#----------------------------------------------------------------------------- | ||
# Start of Script | ||
#----------------------------------------------------------------------------- | ||
Set-LogPath $logPath "publishReleaseCdnLog" | ||
|
||
$jsSdkDir = $releaseFrom | ||
if ([string]::IsNullOrWhiteSpace($jsSdkDir) -eq $true) { | ||
$jsSdkDir = Split-Path (Split-Path $MyInvocation.MyCommand.Path) -Parent | ||
} | ||
|
||
$cacheControl1Year = "public, max-age=31536000, immutable, no-transform"; | ||
$contentType = "text/javascript; charset=utf-8"; | ||
|
||
Write-LogParams | ||
|
||
# You will need to at least have the AzureRM module installed | ||
InstallRequiredModules | ||
$global:connectDetails = ParseCdnStorePath $global:connectDetails | ||
|
||
if ([string]::IsNullOrWhiteSpace($global:connectDetails.sasToken) -eq $true) { | ||
Write-Log "**********************************************************************" | ||
Write-Log "Validating user access" | ||
Write-Log "**********************************************************************" | ||
$global:connectDetails = ValidateAccess $global:connectDetails | ||
} | ||
|
||
Write-Log "======================================================================" | ||
|
||
$version = GetPackageVersion $jsSdkDir | ||
|
||
$releaseFiles = GetReleaseFiles $version # Get the versioned files only | ||
if ($null -eq $releaseFiles -or $releaseFiles.Count -eq 0) { | ||
Write-LogFailure "Unable to find any release files" | ||
} | ||
|
||
Write-Log "Release Files : $($releaseFiles.Count)" | ||
Write-Log "----------------------------------------------------------------------" | ||
|
||
# Publish the full versioned files to all release folders | ||
if ($version.type -eq "release") { | ||
# Normal publishing deployment | ||
PublishFiles $releaseFiles "beta" $cacheControl1Year $contentType $overwrite | ||
PublishFiles $releaseFiles "next" $cacheControl1Year $contentType $overwrite | ||
PublishFiles $releaseFiles "scripts/b" $cacheControl1Year $contentType $overwrite | ||
} | ||
elseif ($version.type -eq "rc") { | ||
PublishFiles $releaseFiles "beta" $cacheControl1Year $contentType $overwrite | ||
PublishFiles $releaseFiles "next" $cacheControl1Year $contentType $overwrite | ||
} | ||
elseif ($version.type -eq "dev" -or $version.type -eq "beta" -or $version.type -eq "nightly") { | ||
# Publish to release type folder folder | ||
PublishFiles $releaseFiles "$($version.type)" $cacheControl1Year $contentType $overwrite | ||
} | ||
else { | ||
# Upload to the test container rather than the supplied one | ||
$global:connectDetails.testOnly = $true | ||
$global:connectDetails.storeContainer = "tst" | ||
PublishFiles $releaseFiles "$($version.type)" $cacheControl1Year $contentType $overwrite | ||
} | ||
|
||
Write-Log "======================================================================" |
Oops, something went wrong.