New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[main] update script for uploading images #2334
Open
siyuniu-ms
wants to merge
22
commits into
main
Choose a base branch
from
siyu/image
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+167
−41
Open
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
ebcfa81
change all size url
siyuniu-ms 63fe30d
Create ai.3.2.0.js.svg
siyuniu-ms 4ff32c9
add script to generate image
siyuniu-ms 4dd8fa5
remove image
siyuniu-ms 3027424
Update package.json
siyuniu-ms d09ff57
create old size image pic
siyuniu-ms bab50bc
create folder also
siyuniu-ms 797a7b3
Merge branch 'main' into siyu/image
MSNev 7bec43e
Merge branch 'main' of https://github.com/microsoft/ApplicationInsigh…
siyuniu-ms 4a4cd4b
remove logs
siyuniu-ms d3d2fc2
Merge branch 'siyu/image' of https://github.com/microsoft/Application…
siyuniu-ms 342f128
Merge branch 'main' into siyu/image
siyuniu-ms ddb881a
Merge branch 'main' into siyu/image
siyuniu-ms 668f787
Update old-size-image-generator.js
siyuniu-ms 7e19f7f
Merge branch 'main' into siyu/image
siyuniu-ms 5623afe
upgrade script
siyuniu-ms 8f889a9
Update publishImgToCdn.ps1
siyuniu-ms f7b9cbe
restore readme and change type
siyuniu-ms 04ef007
Update AzureStorageHelper.psm1
siyuniu-ms ab80a0b
Update AzureStorageHelper.psm1
siyuniu-ms d5fd095
avoid download
siyuniu-ms febaef7
Merge branch 'main' into siyu/image
siyuniu-ms File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
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 | ||
{ | ||
Write-Log "Folder : $jsSdkDir" | ||
|
||
# check if the img dir exists | ||
$parentDir = Split-Path -Path $jsSdkDir -Parent | ||
$imgSrcDir = Join-Path -Path $parentDir -ChildPath "tools\sizeImageGenerator\img" | ||
|
||
Write-Log "Image Folder : $imgSrcDir" | ||
|
||
if (-Not (Test-Path $imgSrcDir)) { | ||
Write-LogWarning "'$imgSrcDir' directory doesn't exist. Generate IMG first."; | ||
exit | ||
} | ||
|
||
$files = New-Object 'system.collections.generic.dictionary[string,string]' | ||
|
||
# Get all files in the imgSrcDir directory | ||
$imgFiles = Get-ChildItem -Path $imgSrcDir -File | ||
|
||
|
||
Write-Log "Adding files"; | ||
# Iterate over each file | ||
foreach ($file in $imgFiles) { | ||
# Call AddReleaseFile for the current file | ||
AddReleaseFile $files $imgSrcDir $file.Name | ||
} | ||
|
||
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 "======================================================================" | ||
|
||
$releaseFiles = GetReleaseFiles | ||
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 "svg") { | ||
# Normal publishing deployment | ||
PublishFiles $releaseFiles "scripts/b" $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 "======================================================================" |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be deleted 😄