Power Automate で Tenant ID を取得する

# なんの為に？
API とかで利用するので、取得できるようにしておくと便利かな、と

# やり方
- Tenant ID は、[list-my-environments](https://docs.microsoft.com/ja-jp/connectors/flowmanagement/#list-my-environments) で Environments を取得
- "Default" で Filter
- Envriontment "Name" から、"Default-" を削除すれば完了

## コード例
```json: extract tenantID
{
    "id": "36cf9579-8c98-4470-bb17-3ab89d19a868",
    "brandColor": "#8C3900",
    "connectionReferences": {
        "shared_flowmanagement": {
            "connection": {
                "id": "/providers/Microsoft.PowerApps/apis/shared_flowmanagement/connections/shared-flowmanagemen-7143b7a4-a5cb-4de9-8676-f10e-b4a3a73d"
            }
        }
    },
    "connectorDisplayName": "Control",
    "icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=",
    "isTrigger": false,
    "operationName": "ExtractTenantID",
    "operationDefinition": {
        "type": "Scope",
        "actions": {
            "List_My_Environments": {
                "type": "OpenApiConnection",
                "inputs": {
                    "host": {
                        "connectionName": "shared_flowmanagement",
                        "operationId": "ListUserEnvironments",
                        "apiId": "/providers/Microsoft.PowerApps/apis/shared_flowmanagement"
                    },
                    "parameters": {},
                    "authentication": {
                        "type": "Raw",
                        "value": "@json(decodeBase64(triggerOutputs().headers['X-MS-APIM-Tokens']))['$ConnectionKey']"
                    }
                },
                "runAfter": {},
                "metadata": {
                    "operationMetadataId": "9a3f17f3-e58a-419e-ae2b-a1d6fe3298c4"
                }
            },
            "Filter_array": {
                "type": "Query",
                "inputs": {
                    "from": "@outputs('List_My_Environments')?['body/value']",
                    "where": "@contains(item()?['name'], 'Default')"
                },
                "runAfter": {
                    "List_My_Environments": [
                        "Succeeded"
                    ]
                },
                "metadata": {
                    "operationMetadataId": "be4305b2-9929-4205-911c-cc5e1b11634e"
                }
            },
            "Compose": {
                "type": "Compose",
                "inputs": "@replace(first(body('Filter_array'))['name'], 'Default-', '')",
                "runAfter": {
                    "Filter_array": [
                        "Succeeded"
                    ]
                },
                "metadata": {
                    "operationMetadataId": "c1d509ab-04e8-4962-80cb-3769fa205fe9"
                }
            }
        },
        "runAfter": {},
        "metadata": {
            "operationMetadataId": "3bd9fe04-cf30-4cf0-a817-27e02b478e32"
        }
    }
}
```

# あとがき
これを使って、FomrsAPIを利用予定