diff --git a/avm/utilities/pipelines/sharedScripts/Set-ModuleReadMe.ps1 b/avm/utilities/pipelines/sharedScripts/Set-ModuleReadMe.ps1 index f94b994249..837b68ecb1 100644 --- a/avm/utilities/pipelines/sharedScripts/Set-ModuleReadMe.ps1 +++ b/avm/utilities/pipelines/sharedScripts/Set-ModuleReadMe.ps1 @@ -595,7 +595,7 @@ function Set-DataCollectionSection { ) # Load content, if required - if ($PreLoadedContent.Keys -notcontains 'TelemetryFileContent') { + if ($PreLoadedContent.Keys -notcontains 'TelemetryFileContent' -or -not $PreLoadedContent['TelemetryFileContent']) { $telemetryUrl = 'https://aka.ms/avm/static/telemetry' try { diff --git a/avm/utilities/pipelines/sharedScripts/helper/Get-SpecsAlignedResourceName.ps1 b/avm/utilities/pipelines/sharedScripts/helper/Get-SpecsAlignedResourceName.ps1 index b71fb9d849..eab33e9c53 100644 --- a/avm/utilities/pipelines/sharedScripts/helper/Get-SpecsAlignedResourceName.ps1 +++ b/avm/utilities/pipelines/sharedScripts/helper/Get-SpecsAlignedResourceName.ps1 @@ -116,7 +116,7 @@ function Get-SpecsAlignedResourceName { $resourceType = $innerResourceTypes | Where-Object { $_ -match $fallbackResourceTypeRegex } if (-not $resourceType) { # if we still don't find anything (because the resource type straight up does not exist, we fall back to itself as the default) - Write-Warning "Resource type [$rawResourceType] does not exist in the API / is custom. Falling back to it as default." + Write-Warning "Resource type [$rawResourceType] cannot be found or does not exist in the API specs / is custom. Falling back to it as default." $resourceType = $rawResourceType } else { Write-Warning ('Failed to find exact match between core matched resource types and [{0}]. Fallback on [{1}].' -f $rawResourceType, (Split-Path $rawResourceType -Parent)) diff --git a/avm/utilities/tools/Set-AVMModule.ps1 b/avm/utilities/tools/Set-AVMModule.ps1 index a583cc9995..761715d206 100644 --- a/avm/utilities/tools/Set-AVMModule.ps1 +++ b/avm/utilities/tools/Set-AVMModule.ps1 @@ -114,24 +114,29 @@ function Set-AVMModule { # Get latest release from Azure/Bicep repository # ---------------------------------------------- $latestReleaseUrl = 'https://api.github.com/repos/azure/bicep/releases/latest' - - $latestReleaseObject = Invoke-RestMethod -Uri $latestReleaseUrl -Method 'GET' - $releaseTag = $latestReleaseObject.tag_name - $latestReleaseVersion = [version]($releaseTag -replace 'v', '') - $latestReleaseUrl = $latestReleaseObject.html_url - - # Get latest installed Bicep CLI version - # -------------------------------------- - $latestInstalledVersionOutput = bicep --version - - if ($latestInstalledVersionOutput -match ' ([0-9]+\.[0-9]+\.[0-9]+) ') { - $latestInstalledVersion = [version]$matches[1] + try { + $latestReleaseObject = Invoke-RestMethod -Uri $latestReleaseUrl -Method 'GET' + } catch { + Write-Warning "Skipping Bicep version check as url [$latestReleaseUrl] did not return a response." } + if ($latestReleaseObject) { + # Only run if connected to the internet / url returns a response + $releaseTag = $latestReleaseObject.tag_name + $latestReleaseVersion = [version]($releaseTag -replace 'v', '') + $latestReleaseUrl = $latestReleaseObject.html_url + + # Get latest installed Bicep CLI version + # -------------------------------------- + $latestInstalledVersionOutput = bicep --version + + if ($latestInstalledVersionOutput -match ' ([0-9]+\.[0-9]+\.[0-9]+) ') { + $latestInstalledVersion = [version]$matches[1] + } - # Compare the versions - # -------------------- - if ($latestInstalledVersion -ne $latestReleaseVersion) { - Write-Warning """ + # Compare the versions + # -------------------- + if ($latestInstalledVersion -ne $latestReleaseVersion) { + Write-Warning """ You're not using the latest available Bicep CLI version [$latestReleaseVersion] but [$latestInstalledVersion]. You can find the latest release at: $latestReleaseUrl. @@ -140,10 +145,10 @@ For other OSs, please refer to the Bicep documentation (https://learn.microsoft. Note: The 'Bicep CLI' version (bicep --version) is not the same as the 'Azure CLI Bicep extension' version (az bicep version). """ - } else { - Write-Verbose "You're using the latest available Bicep CLI version [$latestInstalledVersion]." + } else { + Write-Verbose "You're using the latest available Bicep CLI version [$latestInstalledVersion]." + } } - } # Load recurring information we'll need for the modules @@ -160,10 +165,12 @@ Note: The 'Bicep CLI' version (bicep --version) is not the same as the 'Azure CL if (($rawResponse.Headers['Content-Type'] | Out-String) -like '*text/plain*') { $TelemetryFileContent = $rawResponse.Content -split '\n' } else { - throw "Failed to telemetry information from [$telemetryUrl]." # Incorrect Url (e.g., points to HTML) + Write-Warning "Failed to fetch telemetry information from [$telemetryUrl]. NOTE: You should re-run the script again at a later stage to ensure all data is collected and the readme correctly populated." # Incorrect Url (e.g., points to HTML) + $TelemetryFileContent = $null } } catch { - throw "Failed to telemetry information from [$telemetryUrl]." # Invalid url + Write-Warning "Failed to fetch telemetry information from [$telemetryUrl]. NOTE: You should re-run the script again at a later stage to ensure all data is collected and the readme correctly populated." # Invalid url + $TelemetryFileContent = $null } # create reference as it must be loaded in the thread to work