Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.81k forks source link

`Get-AzContainerAppJobExecution` is missing most properties #24054

Open zsharp-gls opened 7 months ago

zsharp-gls commented 7 months ago

Description

When running Get-AzContainerAppJobExecution, the resulting powershell object is missing most properties from the execution, like Status, StartTime, etc...

Issue script & Debug output

PS /> $DebugPreference='Continue'
PS /> $ResourceGroup = "resource-group"
PS /> $ContainerName = "container-app-test"
PS /> $job = Start-AzContainerAppJob -Name $ContainerName -ResourceGroupName $ResourceGroup
DEBUG: 4:03:54 PM - GetAzureRMContextCommand begin processing with ParameterSet 'GetSingleContext'.
DEBUG: 4:03:54 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 4:03:54 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 4:03:54 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 4:03:54 PM - GetAzureRMContextCommand end processing.
DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.App/jobs/container-app-test/start?api-version=2023-05-01
DEBUG: RequestCreated: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.App/jobs/container-app-test/start?api-version=2023-05-01
DEBUG: HeaderParametersAdded:
DEBUG: BodyContentSet:
DEBUG: 4:03:54 PM - [ConfigManager] Got nothing from [EnableLoginByWam], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
POST

Absolute Uri:
https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.App/jobs/container-app-test/start?api-version=2023-05-01

Headers:
x-ms-unique-id                : 5
x-ms-client-request-id        : 2fe136e4-65b3-4761-94a5-27dec09ecaa4
CommandName                   : Start-AzContainerAppJob
FullCommandName               : Start-AzContainerAppJob_StartExpanded
ParameterSetName              : __AllParameterSets
User-Agent                    : AzurePowershell/v11.2.0,PSVersion/v7.4.0,Az.App/0.0.0

Body:
{}

DEBUG: BeforeCall:
DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
Vary                          : Accept-Encoding
x-ms-ratelimit-remaining-subscription-writes: 1199
api-supported-versions        : 2022-11-01-preview, 2023-04-01-preview, 2023-05-01, 2023-05-02-preview, 2023-08-01-preview, 2023-11-02-preview, 2024-02-02-preview
X-Powered-By                  : ASP.NET
x-ms-request-id               : 7e82299f-2778-4ecb-b898-e60033a2f289
x-ms-correlation-request-id   : 7e82299f-2778-4ecb-b898-e60033a2f289
x-ms-routing-request-id       : NORTHCENTRALUS:20240126T160355Z:7e82299f-2778-4ecb-b898-e60033a2f289
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
X-Cache                       : CONFIG_NOCACHE
X-MSEdge-Ref                  : Ref A: 8A496B5DEEC941DA967B0E38E22BB10A Ref B: CH1AA2020616045 Ref C: 2024-01-26T16:03:54Z
Date                          : Fri, 26 Jan 2024 16:03:54 GMT

Body:
{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.App/jobs/container-app-test/executions/container-app-test-8vb7sbp",
  "name": "container-app-test-8vb7sbp"
}

DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: AzureQoSEvent:  Module: Az.App:1.0.0; CommandName: Start-AzContainerAppJob; PSVersion: 7.4.0; IsSuccess: True; Duration: 00:00:00.9884090
PS /> $execution = Get-AzContainerAppJobExecution -JobName $ContainerName -Name $job.Name -ResourceGroupName $ResourceGroup
DEBUG: 4:04:05 PM - GetAzureRMContextCommand begin processing with ParameterSet 'GetSingleContext'.
DEBUG: 4:04:05 PM - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 4:04:05 PM - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 4:04:05 PM - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 4:04:05 PM - GetAzureRMContextCommand end processing.
DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.App/jobs/container-app-test/executions/container-app-test-8vb7sbp?api-version=2023-05-01
DEBUG: RequestCreated: /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.App/jobs/container-app-test/executions/container-app-test-8vb7sbp?api-version=2023-05-01
DEBUG: HeaderParametersAdded:
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.App/jobs/container-app-test/executions/container-app-test-8vb7sbp?api-version=2023-05-01

Headers:
x-ms-unique-id                : 6
x-ms-client-request-id        : 29d26dff-4640-4967-85dc-ed2904bd9418
CommandName                   : Get-AzContainerAppJobExecution
FullCommandName               : Get-AzContainerAppJobExecution_Job
ParameterSetName              : __AllParameterSets
User-Agent                    : AzurePowershell/v11.2.0,PSVersion/v7.4.0,Az.App/0.0.0

Body:

DEBUG: BeforeCall:
DEBUG: 4:04:05 PM - [ConfigManager] Got nothing from [EnableLoginByWam], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
Vary                          : Accept-Encoding
x-ms-ratelimit-remaining-subscription-reads: 11999
api-supported-versions        : 2022-11-01-preview, 2023-04-01-preview, 2023-05-01, 2023-05-02-preview, 2023-08-01-preview, 2023-11-02-preview, 2024-02-02-preview
X-Powered-By                  : ASP.NET
x-ms-request-id               : 21ca6fbf-7bcc-417d-9ad0-dfd782ab8c2e
x-ms-correlation-request-id   : 21ca6fbf-7bcc-417d-9ad0-dfd782ab8c2e
x-ms-routing-request-id       : NORTHCENTRALUS:20240126T160406Z:21ca6fbf-7bcc-417d-9ad0-dfd782ab8c2e
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
X-Cache                       : CONFIG_NOCACHE
X-MSEdge-Ref                  : Ref A: 6642DB0D4A4644D4A0ED5A0F614C7619 Ref B: CH1AA2020616045 Ref C: 2024-01-26T16:04:06Z
Date                          : Fri, 26 Jan 2024 16:04:06 GMT

Body:
{
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.App/jobs/container-app-test/executions/container-app-test-8vb7sbp",
  "name": "container-app-test-8vb7sbp",
  "type": "Microsoft.App/jobs/executions",
  "properties": {
    "status": "Running",
    "startTime": "2024-01-26T16:03:55+00:00",
    "template": {
      "containers": [
        {
          "image": "my-org.azurecr.io/docker-test:v2",
          "name": "container-app-test",
          "env": [
            {
              "name": "CONTAINER_APP_JOB_NAME",
              "value": "container-app-test"
            }
          ],
          "resources": {
            "cpu": 0.5,
            "memory": "1Gi",
            "ephemeralStorage": ""
          }
        }
      ],
      "initContainers": []
    }
  }
}

DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: AzureQoSEvent:  Module: Az.App:1.0.0; CommandName: Get-AzContainerAppJobExecution; PSVersion: 7.4.0; IsSuccess: True; Duration: 00:00:00.6665176
PS /> $execution.Status
PS /> $execution.ToJsonString()
{
  "name": "container-app-test-8vb7sbp",
  "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resource-group/providers/Microsoft.App/jobs/container-app-test/executions/container-app-test-8vb7sbp",
  "type": "Microsoft.App/jobs/executions"
}

Environment data

PS /> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             Ubuntu 20.04.6 LTS
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Running on Docker. Image is mcr.microsoft.com/azure-powershell:latest (e543c0f068a0). Docker engine is v24.0.7

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.15.0                Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzC…
Script     1.0.0                 Az.App                              {Disable-AzContainerAppRevision, Enable-AzCon…

Error output

No results pertinent to the debugged lines above
wyunchi-ms commented 7 months ago

This is caused by the mismatch between swagger and service response. But this is fix in https://github.com/Azure/azure-rest-api-specs/commit/8e982a3998c1fdfffb897a2894ff29f9bbb8074d. The solution is to refresh the Az.App module.

zsharp-gls commented 7 months ago

Thanks for the pointer! This might be an issue with the azure-powershell docker container then. Here's what I get when I try to Update-Module on Az.App

PS C:\Users\zsharp> docker image list mcr.microsoft.com/azure-powershell
REPOSITORY                           TAG       IMAGE ID       CREATED       SIZE
mcr.microsoft.com/azure-powershell   latest    e543c0f068a0   3 weeks ago   946MB
PS C:\Users\zsharp> docker run -it mcr.microsoft.com/azure-powershell:latest
PowerShell 7.4.0
PS /> Start-AzContainerAppJob

cmdlet Start-AzContainerAppJob at command pipeline position 1
Supply values for the following parameters:
Name:
PS /> # Ctrl-C to skip entering values
PS /> Get-Module Az*

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.15.0                Az.Accounts                         {Add-AzEnvironme…
Script     1.0.0                 Az.App                              {Disable-AzConta…

PS /> Update-Module Az.App
Install-Package: Unable to find repository '/latest'. Use Get-PSRepository to see all available repositories.
PS />
redoz commented 7 months ago

This is caused by the mismatch between swagger and service response. But this is fix in Azure/azure-rest-api-specs@8e982a3. The solution is to refresh the Az.App module.

@wyunchi-ms Refresh as in release a new version, because updating to 1.0.0 doesn't seem to have included the fix?

Is there any kind of work-around for this at the moment?

mario-d-s commented 3 months ago

@wyunchi-ms this issue does not seem to be resolved, at least not with AZ.App v1.0.0.

prutsert commented 2 months ago

As a workaround, you can retrieve the Azure Resource of the Container App Job Execution, and use the Properties object from there:

$ResourceGroup = "resource-group"
$ContainerName = "container-app-test"
$job = Start-AzContainerAppJob -Name $ContainerName -ResourceGroupName $ResourceGroup
$resource = Get-AzResource -id $job.id
PS /> $resource.Properties.status
Running
JustinGrote commented 1 week ago

Related and may warrant a separate issue, Get-AzContainerAppJobExecution should support list if a jobID is not supplied and return all jobs.

Equivalent: invoke-azrestmethod 'https://management.azure.com/subscriptions/x/resourceGroups/x/providers/Microsoft.App/jobs/x/executions?api-version=2024-02-02-preview' |% content | convertfrom-json -depth 9 |% value