3
3

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 5 years have passed since last update.

Power BI service の XMLA Endpoint Read / Write をちょろっと試す

Last updated at Posted at 2020-04-26

現時点では Preview ではあるけれども、 Power BI Service で XMLA Read / Write がサポートされたわけです。Power BI 勉強会 #17 でデモなどをしたんだけど、SSMS 使わなかったんよね。

このあたりの話は Christian をフォローしておくとよいです。

Power BI Desktop もサポートされるようなデモもやっていたので興味ある人は見ておいた方がよい。

環境

Power BI Premium キャパシティが割り当てられた Power BI ワークスペースが必要。
image.png

ちょっとしたお試しとしてはPower BI Premium の購入はハードルが高いかも。時間課金の Power BI Embedded でも利用可能なのでこちらで試してもよい。よわよわスペックではあるけれども、A1 でも動作するはずです。

設定

[Admin portal] - [Capacity settings] - (対象のキャパシティ) - [Workloads] - [XMLA Endpoint]
image.png

確認

SQL Server Management Studio(SSMS) | Microsoft Docs で接続。
image.png
Server type は "Analysis Services"、Server Name は "powerbi://api.powerbi.com/v1.0/myorg/{ワークスペース名}" って感じになるけれど、リダイレクトされて内部の Analysis Server に接続されるっぽい。

ワークスペースの [Settings] - [Premium] で確認/コピーとか
image.png
Server property 見るとこんな感じ
image.png

クエリを発行して操作

SSMSを使って XMLA Endpoint に クエリを発行する
image.png

Tabular Model Scripting Language (TMSL)

Create command (TMSL)

XMLAQuery(TMSL)
{
  "create": {
    "database": {
      "name": "Demo1",
      "compatibilityLevel": 1500,
      "model": {
        "tables": [
          {
            "name": "Table1",
            "columns": [
              {
                "name": "Column1",
                "dataType": "string",
                "sourceColumn": "Column1"
              }
            ],
            "partitions": [
              {
                "name": "Partition_Table1",
                "source": {
                  "type": "m",
                  "expression": [
                    "let\r",
                    "    Source = #table(\r",
                    "        type table [Column1 = text],\r",
                    "        {\r",
                    "            {\"Apple\"}, {\"Gorilla\"}, {\"Rappa\"}\r",
                    "        }\r",
                    "    )\r",
                    "in\r",
                    "    Source"
                  ]
                }
              }
            ]
          }
        ]
      }
    }
  }
}

Power BI データモデル は配置されているので、レポートを作成することは可能。ただ、データがまだない状態。
image.png
Table に紐づく Partition の Status は "NoData"
image.png

Refresh command (TMSL)

Refresh command で各オブジェクト Database, Table, Partition へ適用することができて、ここでは Database オブジェクトに対して実行する。Refresh type に "automatic" を選択することで必要なだけの Refresh を期待した。Status が "Ready" 以外の Partition にも適用されるので。

XMLAQuery(TMSL)
{
  "refresh": {
    "type": "automatic",
    "objects": [
      {
        "database": "Demo1"
      }
    ]
  }
}

Table に紐づく Partition の Status は "Ready" に
image.png
image.png

Delete command (TMSL)

Damo1 データセット こと "Demo1" データベース の削除

XMLAQuery(TMSL)
{
  "delete": {
    "object": {
      "database": "Demo1"
    }
  }
}

思ったこと🙄

まだまだ触れていかないとだなと思った。
SSMS で試すことにはメリットがあって、TMSL ってどんな感じに記述するんだ🙄ってことなんだけど、いろんなところでスクリプトを出力してくれるので、それ見て感じていけばよいだろうと。

その他

3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?