How to see logs from a Powershell script in Deployment Scripts? #16737
-
| I have this template below where I am creating role assignments through a PowerShell script which I have some  Template: @description('Add role assignments to any resource using a PowerShell script.')
resource addRoleAssignments 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
  // Disable the rule because the resource name is dynamic and cannot be stable, check docks at https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/deployment-script-template#run-script-more-than-once
  #disable-next-line use-stable-resource-identifiers
  name: 'AddRoleAssignments'
  location: resourceGroup().location
  kind: 'AzurePowerShell'
  properties: {
    azPowerShellVersion: '13.2'
    environmentVariables: []
    scriptContent: loadTextContent('AddRoleAssignments.ps1')
    arguments: '-SubscriptionId ${subscriptionId} -ResourceGroup ${resourceGroupName} -RoleAssignmentsBase64 "${allRoleAssignmentsEncoded}"'
    cleanupPreference: 'OnSuccess'
    retentionInterval: 'P1D'
    // Deployment scripts are idempotent, so we can use utcnow on Tag to force an update
    forceUpdateTag: 'Run-${timestamp}'
  }
}
@description('Output all role assignments.')
output allRoleAssignments array = allRoleAssignments
@description('Output the number of successful role assignments.')
output successCount int = addRoleAssignments.properties.outputs.success
@description('Output the number of failed role assignments.')
output failsCount int = addRoleAssignments.properties.outputs.fails
@description('Output the number of skipped role assignments.')
output skippingCount int = addRoleAssignments.properties.outputs.skippingIf I use Logs from deployment-script-azcli-inputs-outputs example: @description('Logs from the deployment script.')
resource logs 'Microsoft.Resources/deploymentScripts/logs@2023-08-01' existing = {
  parent: addRoleAssignments
  name: 'default'
}
@description('The logs written by the script')
output logs array = split(logs.properties.log, '\n')I get this error: 
 I cannot see nothing here in Logs: | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
| The reason was icons, such as ❌, I had some over my powershell script that was causing the missing logs from Azure (despite working locally). | 
Beta Was this translation helpful? Give feedback.

The reason was icons, such as ❌, I had some over my powershell script that was causing the missing logs from Azure (despite working locally).