Receiving an error when trying to deploy ARM template

JTurn01 0 Reputation points
2024-07-08T16:35:00.7666667+00:00

I created a runbook within an Automation Account to go out and grab logic app templates and send them to a blob storage container.
Here is the powershell script that gets the templates

# Ensure modules are imported, should already be imported via modules
Import-Module Az.Accounts -Force
Import-Module LogicAppTemplate -Force
# Variables
$resourceGroupName = ""
$storageAccountName = ""
$containerName = ""
$subscriptionId = ""
$tenantId = ""
# Login to Azure
Connect-AzAccount -Identity
# Set the subscription context
Set-AzContext -SubscriptionId $subscriptionId -TenantId $tenantId
# Create a temporary directory for storing templates
$tempDir = "C:\temp\logicapp-templates"
if (-Not (Test-Path -Path $tempDir)) {
    New-Item -ItemType Directory -Path $tempDir
}
# Get all Logic Apps in the resource group
$logicApps = Get-AzLogicApp -ResourceGroupName $resourceGroupName
foreach ($logicApp in $logicApps) {
    $logicAppName = $logicApp.Name
    $templateOutputPath = "$tempDir\$logicAppName-template.json"
    # Export Logic App template using PowerShell
    $token = (Get-AzAccessToken -ResourceUrl "https://management.azure.com").Token
    Get-LogicAppTemplate -LogicApp $logicAppName -ResourceGroup $resourceGroupName -SubscriptionId $subscriptionId -Token $token -Verbose | Out-File -FilePath $templateOutputPath -Encoding utf8
    # Check if the template file was created successfully
    if (Test-Path -Path $templateOutputPath) {
        # Upload template to Blob Storage
        $storageContext = (Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName).Context
        Set-AzStorageBlobContent -File $templateOutputPath -Container $containerName -Blob "$logicAppName-template.json" -Context $storageContext -Force
        # Remove the local file after upload
        Remove-Item $templateOutputPath
    } else {
        Write-Output "Failed to create template for Logic App: $logicAppName"
    }
}

The issue I am having is when trying to deploy the template from the .JSON file attached (attached as .txt file). Block-Domain-Manual-template.txt I have replaced some data with junk values.

I am receiving this error which is preventing me from deploying the template:

{
  "message": "Cannot read properties of undefined (reading 'subscriptionId')",
  "name": "TypeError",
  "stack": "TypeError: Cannot read properties of undefined (reading 'subscriptionId')\n    at Object.w [as getFormTemplateDeploymentOptions] (https://afd-v2.hosting.portal.azure.net/createuidef/Content/Dynamic/l7ZIQZxDCTNj.js:78:2663)\n    at k._getTemplateDeploymentOptions (https://afd-v2.hosting.portal.azure.net/createuidef/Content/Dynamic/e5PKmB0lSbeb.js:27:14773)\n    at k._getFormTemplateDeploymentOptions (https://afd-v2.hosting.portal.azure.net/createuidef/Content/Dynamic/e5PKmB0lSbeb.js:27:13578)\n    at https://afd-v2.hosting.portal.azure.net/createuidef/Content/Dynamic/e5PKmB0lSbeb.js:15:16695",
  "extension": "Microsoft_Azure_CreateUIDef"
}

I am also receiving this error, but this error does not seem to be preventing me from trying to deploy the template:
User's image

I am unsure as to what these errors mean, looking for some insight on how I might go about resolving them.

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,179 questions
{count} votes