티스토리 뷰

Cloud/Public Cloud

Logic Apps for Azure Resource

Jacob_baek 2023. 4. 17. 22:02

Logic Apps 에서 Azure Resourece Manager 사용시 어떻게 사용할지 좀 애매한 부분들이 있어 이를 정리하고자 한다.

Prerequisite

먼저 logic Apps 로 control할 resource에 대한 기본정보를 확인한다.
아래와 같이 특정 provider에 control할 resource의 resourceType을 확인한다.

jacob@laptop:~ $ az provider list --query "[?namespace == 'Microsoft.ContainerService'].resourceTypes[].resourceType" -o json
[
  "ManagedClusters/eventGridFilters",
  "containerServices",
  "fleetMemberships",
  "fleets",
  "fleets/members",
  "locations",
  "locations/notifyNetworkSecurityPerimeterUpdatesAvailable",
  "locations/operationresults",
  "locations/operations",
  "locations/orchestrators",
  "locations/osOptions",
  "managedClusters",
  "managedclustersnapshots",
  "operations",
  "snapshots",
  "locations/trustedAccessRoles"
]

이후 해당 resourceType에서 사용가능한 apiVersion을 확인한다.

jacob@laptop:~ $ az provider list --query "[?namespace == 'Microsoft.ContainerService'].resourceTypes[] | [?resourceType == 'managedClusters'].apiVersions" -o json
[
  [
    "2023-03-02-preview",
    "2023-03-01",
    "2023-02-02-preview",
    "2023-02-01",
    "2023-01-02-preview",
    "2023-01-01",
    "2022-11-02-preview",
    "2022-11-01",
    "2022-10-02-preview",
    "2022-09-02-preview",
    "2022-09-01",
    "2022-08-03-preview",
    "2022-08-02-preview",
    "2022-08-01",
    "2022-07-02-preview",
    "2022-07-01",
    "2022-06-02-preview",
    "2022-06-01",
    "2022-05-02-preview",
    "2022-04-02-preview",
    "2022-04-01",
    "2022-03-02-preview",
    "2022-03-01",
    "2022-02-02-preview",
    "2022-02-01",
    "2022-01-02-preview",
    "2022-01-01",
    "2021-11-01-preview",
    "2021-10-01",
    "2021-09-01",
    "2021-08-01",
    "2021-07-01",
    "2021-05-01",
    "2021-03-01",
    "2021-02-01",
    "2020-12-01",
    "2020-11-01",
    "2020-09-01",
    "2020-07-01",
    "2020-06-01",
    "2020-04-01",
    "2020-03-01",
    "2020-02-01",
    "2020-01-01",
    "2019-11-01",
    "2019-10-01",
    "2019-08-01",
    "2019-06-01",
    "2019-04-01",
    "2019-02-01",
    "2018-08-01-preview",
    "2018-03-31",
    "2017-08-31"
  ]
]

How to write

아래 operation들을 확인하고 아래중 Azure Resource Manager를 사용하여 resource control을 수행한다.
(참고로 azure resource manager를 이용하여 request body를 추가하여 좀더 구체화된 control을 수행할 수 있다.)

실제 Logic Apps의 designer를 구성한 화면이다.

위 designer를 code 기반으로 표현하면 다음과 같다.

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Invoke_resource_operation_2": {
                "inputs": {
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['arm']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "/subscriptions/@{encodeURIComponent('11111111-1111-1111-1111-111111111111')}/resourcegroups/@{encodeURIComponent('xxxxxx-rg')}/providers/@{encodeURIComponent('Microsoft.ContainerService')}/@{encodeURIComponent('managedClusters/xxxxxx-cluster')}/@{encodeURIComponent('start')}",
                    "queries": {
                        "x-ms-api-version": "2023-01-02-preview"
                    }
                },
                "runAfter": {},
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "Recurrence": {
                "evaluatedRecurrence": {
                    "frequency": "Week",
                    "interval": 1,
                    "schedule": {
                        "hours": [
                            "9"
                        ],
                        "minutes": [
                            0
                        ],
                        "weekDays": [
                            "Monday",
                            "Tuesday",
                            "Wednesday",
                            "Thursday",
                            "Friday"
                        ]
                    }
                },
                "recurrence": {
                    "frequency": "Week",
                    "interval": 1,
                    "schedule": {
                        "hours": [
                            "9"
                        ],
                        "minutes": [
                            0
                        ],
                        "weekDays": [
                            "Monday",
                            "Tuesday",
                            "Wednesday",
                            "Thursday",
                            "Friday"
                        ]
                    }
                },
                "type": "Recurrence"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "arm": {
                    "connectionId": "/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/xxxxxx-rg/providers/Microsoft.Web/connections/arm-1",
                    "connectionName": "arm-1",
                    "id": "/subscriptions/11111111-1111-1111-1111-111111111111/providers/Microsoft.Web/locations/koreacentral/managedApis/arm"
                }
            }
        }
    }
}

Disclaim
Microsoft의 공식적인 문서가 아닌 개인의 경험을 바탕으로 작성된 내용임을 알립니다.
This is not official document published by Microsoft. Note that this document is based on personal experience.

'Cloud > Public Cloud' 카테고리의 다른 글

how to check ACR login user  (0) 2025.08.04
Bicep  (0) 2023.11.07
Azure Custom Policy for AKS cluster  (0) 2023.05.08
Azure Kubernetes Service and Network Policy  (0) 2023.04.06
Kata Container on AKS  (0) 2023.03.09
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/09   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함