1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Power Automate で Tenant ID を取得する

Last updated at Posted at 2021-08-25

なんの為に?

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

やり方

  • Tenant ID は、list-my-environments で Environments を取得
  • "Default" で Filter
  • Envriontment "Name" から、"Default-" を削除すれば完了

コード例

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を利用予定

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?