Tenemos una aplicación lógica que sondea el bus de servicio cada 30 minutos en busca de mensajes. Me gustaría usar Postman para actualizar la frecuencia de sondeo a 30 segundos para la prueba.

Puedo usar la API de Azure para obtener detalles del flujo de trabajo asociado con la aplicación lógica y luego obtener el disparador en ese flujo de trabajo asociado con el sondeo del bus de servicio. Esto devuelve JSON como:

{
    "properties": {
        "provisioningState": "Succeeded",
        "createdTime": "2019-08-13T21:08:14.8768439Z",
        "changedTime": "2019-10-21T14:32:46.0204187Z",
        "state": "Enabled",
        "status": "Running",
        "lastExecutionTime": "2019-10-21T14:32:04.149971Z",
        "nextExecutionTime": "2019-10-21T14:32:46.285845Z",
        "recurrence": {
            "frequency": "Second",
            "interval": 30
        },
        "workflow": {
            "id": "/subscriptions/<subscription>/resourceGroups/<resource-group-name>/providers/Microsoft.Logic/workflows/<workflow-name>/versions/08586299385548076458",
            "name": "08586299385548076458",
            "type": "Microsoft.Logic/workflows/versions"
        }
    },
    "id": "/subscriptions/<subscription>/resourceGroups/<resource-group-name>/providers/Microsoft.Logic/workflows/<workflow-name>/triggers/When_a_message_is_received_in_a_topic_subscription_(auto-complete)",
    "name": "When_a_message_is_received_in_a_topic_subscription_(auto-complete)",
    "type": "Microsoft.Logic/workflows/triggers"
} 

En la estructura anterior, quiero PATCHAR "recurrence" : { "frequency": "Second" } a "recurrence" : { "frequency": "Minute" }

Al mirar la documentación de la API REST, no está claro a mi si esto es posible? Veo que Trigger tiene una opción setState y una de las propiedades es RecurrenceFrequency, pero si intento usar esto, me devuelve el siguiente error:

{
    "error": {
        "code": "WorkflowTriggerSetStateNotSupported",
        "message": "The workflow trigger 'When_a_message_is_received_in_a_topic_subscription_(auto-complete)' of type 'ApiConnection' does not support the set state action."
    }
}

Realmente agradecería si alguien me pudiera decir si esto es posible, qué estoy haciendo mal o señalarme un ejemplo.

0
steveg 21 oct. 2019 a las 18:20

1 respuesta

La mejor respuesta

Respuesta actualizada y solución alternativa

Desafortunadamente, a pesar de que la documentación de la API sugiere que es posible, no puede usar setState para actualizar un disparador de ningún tipo, nativo o administrado, habilitado o no.

  • Respuesta nativa:

{"error":{"code":"WorkflowTriggerSetStateNotSupported","message":"The workflow trigger 'Recurrence' of type 'Recurrence' does not support the set state action."}}

  • Respuesta gestionada:

{"error":{"code":"WorkflowTriggerSetStateNotSupported","message":"The workflow trigger 'sbAuto' of type 'ApiConnection' does not support the set state action."}}

Tampoco puede usar el verbo PATCH para actualizar un flujo de trabajo:

{"error":{"code":"PatchWorkflowPropertiesNotSupported","message":"The request to patch workflow 'XXXXXXX' is not supported. None of the fields inside the properties object can be patched."}}

Le planteé este problema a Microsoft.

Sin embargo...

Lo que es posible es usar el verbo PUT para actualizar el flujo de trabajo.

Para lograr esto, es mejor recuperar el flujo de trabajo usando el verbo GET, actualizar el objeto de repetición JSON y volver a emitir usando un PUT (Crear o Actualizar).

Mi ejemplo a continuación obtiene la definición de un flujo de trabajo que creé tempotestla .

Solicitud:

GET https://management.azure.com/subscriptions/651a2541-8d19-42a0-85fe-89a9eee81c48/resourceGroups/TechSouth/providers/Microsoft.Logic/workflows/tempotestla?api-version=2016-06-01 HTTP/1.1
User-Agent: Fiddler
Host: management.azure.com
Content-Type: application/json
Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Length: 0

Respuesta:

HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 1431
Content-Type: application/json; charset=utf-8
Expires: -1
Vary: Accept-Encoding
x-ms-request-id: uksouth:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Strict-Transport-Security: max-age=31536000; includeSubDomains
x-ms-ratelimit-remaining-subscription-resource-requests: 19999
x-ms-correlation-request-id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
x-ms-routing-request-id: UKSOUTH2:20191022T160012Z:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
X-Content-Type-Options: nosniff
Date: Tue, 22 Oct 2019 16:00:11 GMT

{
    "properties":{
        "provisioningState":"Succeeded",
        "createdTime":"2019-10-22T13:27:18.8425031Z",
        "changedTime":"2019-10-22T15:59:39.3684114Z",
        "state":"Disabled",
        "version":"xxxxxxxxxxxxxxxxxxxx",
        "accessEndpoint":"https://prod-00.uksouth.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "definition":{
            "$schema":"https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "contentVersion":"1.0.0.0",
            "parameters":{

            },
            "triggers":{
                "Recurrence":{
                    "recurrence":{
                        "frequency":"Hour",
                        "interval":5
                    },
                    "type":"Recurrence"
                }
            },
            "actions":{
                "Terminate":{
                    "runAfter":{

                    },
                    "type":"Terminate",
                    "inputs":{
                        "runStatus":"Succeeded"
                    }
                }
            },
            "outputs":{

            }
        },
        "parameters":{

        },
        "endpointsConfiguration":{
            "workflow":{
                "outgoingIpAddresses":[
                    {
                        "address":"51.140.74.14"
                    },
                    {
                        "address":"51.140.73.85"
                    },
                    {
                        "address":"51.140.78.44"
                    },
                    {
                        "address":"51.140.137.190"
                    },
                    {
                        "address":"51.140.153.135"
                    },
                    {
                        "address":"51.140.28.225"
                    },
                    {
                        "address":"51.140.142.28"
                    },
                    {
                        "address":"51.140.158.24"
                    }
                ],
                "accessEndpointIpAddresses":[
                    {
                        "address":"51.140.79.109"
                    },
                    {
                        "address":"51.140.78.71"
                    },
                    {
                        "address":"51.140.84.39"
                    },
                    {
                        "address":"51.140.155.81"
                    }
                ]
            },
            "connector":{
                "outgoingIpAddresses":[
                    {
                        "address":"51.140.80.51"
                    },
                    {
                        "address":"51.140.148.0/28"
                    }
                ]
            }
        }
    },
    "id":"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxxxxxx/providers/Microsoft.Logic/workflows/tempotestla",
    "name":"tempotestla",
    "type":"Microsoft.Logic/workflows",
    "location":"uksouth",
    "tags":{

    }
}

Esta es la página de descripción general de mi flujo de trabajo:


Workflow Overview - 5 Hour Trigger


Desde aquí, si está utilizando código o script orientado a objetos, puede deserializar el cuerpo de la respuesta y cambiar el intervalo:

objResponse.properties.definition.triggers.<TriggerType>.<TriggerName>.frequency = "Minute"

Luego, reserialice su objeto y envíelo de regreso a la API en una solicitud PUT. Aquí estoy cambiando las horas a los días:

PUT https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourcegroups/xxxxxxxxx/providers/Microsoft.Logic/workflows/tempotestla?api-version=2016-06-01 HTTP/1.1
User-Agent: Fiddler
Host: management.azure.com
Content-Type: application/json
Authorization: Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Content-Length: 1534

{
    "properties":{
        "provisioningState":"Succeeded",
        "createdTime":"2019-10-22T15:25:16.1635472Z",
        "changedTime":"2019-10-22T15:25:16.153712Z",
        "state":"Disabled",
        "version":"08586298489693318400",
        "accessEndpoint":"https://prod-00.uksouth.logic.azure.com:443/workflows/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
        "definition":{
            "$schema":"https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
            "contentVersion":"1.0.0.0",
            "parameters":{

            },
            "triggers":{
                "Recurrence":{
                    "recurrence":{
                        "frequency":"Day",
                        "interval":5
                    },
                    "type":"Recurrence"
                }
            },
            "actions":{
                "Terminate":{
                    "runAfter":{

                    },
                    "type":"Terminate",
                    "inputs":{
                        "runStatus":"Succeeded"
                    }
                }
            },
            "outputs":{

            }
        },
        "parameters":{

        },
    },
    "id":"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxxxxxxx/providers/Microsoft.Logic/workflows/tempotestla",
    "name":"tempotestla",
    "type":"Microsoft.Logic/workflows",
    "location":"uksouth",
    "tags":{

    }
}

Debería obtener un objeto actualizado en el cuerpo de la respuesta.

Aquí está mi página de resumen de flujo de trabajo después de emitir la solicitud:


5 Day Trigger


Espero que esto ayude.

1
Architect Jamie 22 oct. 2019 a las 16:35