Giter Club home page Giter Club logo

azure-analysis-services-http-sample's Introduction

This sample is a HTTP proxy for XMLA endpoints, intended for use with Power BI Premium or Azure Analysis Services.

NB: Power BI now supports a REST API for sending queries to DataSets, which can be used without having to deploy an additional endpoint. See https://powerbi.microsoft.com/en-us/blog/announcing-the-public-preview-of-power-bi-rest-api-support-for-dax-queries/

It's implemented as ASP.NET Core 5 API Project. The main API is /api/Query which allows you to POST a DAX query and receive the results as a JSON result.

The sample is coded to pass-through authentication from the client to the XMLA endpoint. So to call the API either use HTTP BASIC auth over HTTPS, passing credentials with the request. It's highly advised that this be a Service Principal, rather than an AAD user. To specify a Service Principal use a UserName of the form app:[ClientID]@[TenantID], and pass a Client Secret as the Password.

For better security, instead of passing a UserName/Password using HTTP BASIC auth, fetch a Bearer token for your XMLA endpoint. To fetch a token use the Resource ID https://analysis.windows.net/powerbi/api for Power BI, or https://*.asazure.windows.net for Azure Analysis Services

Configuration

To get started modify the configuration settings to set

Server: this can be the XMLA endpoint of an Azure Analysis Services Server,

asazure://[region name].asazure.windows.net/[AAS Server Name]

or a Power BI Premium Workspace

powerbi://api.powerbi.com/v1.0/myorg/[Workspace Name]

Or for local testing you can use an Analysis Services Server

localhost

If you specify an Analysis Services Server the API will attempt to connect using Windows Integrated Authentication, instead of using passthrough Auth. This is handy for testing of the endpont itself, but is not intended for production deployment.

DefaultDatabase this is the default databae to use. If the user doesn't specify a database in the route, this database will be used. And queries to the /api/Databases endpoint will use this database too. To specify a non-default database, use the /api/{database}/Query or /api/{database}/Tables endpoints.

TenantId this is the tenantID to perform authentication against in Auth scenarios where the user hasn't passed a Bearer token or a Service Principal with the TenantID specified.

You can specify these setting through any configuration provider. If you are considering committing your code back to a GitHub public repository, you should specify these in a local secrets store, per https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?view=aspnetcore-5.0&tabs=windows, or in a git-ignored settings file.

Example appsettings.json

{
    "Server": "powerbi://api.powerbi.com/v1.0/myorg/[Workspace Name]",
    "DefaultDatabase": "[Your AAS Database or Power BI Data Set Name]",
    "TenantId": "[Your Tenant ID]",
    "Logging": {
        "LogLevel": {
            "Default": "Information",
            "Microsoft": "Warning",
            "Microsoft.Hosting.Lifetime": "Information",
            "Microsoft.Samples.XMLA.HTTP.Proxy.Controllers.QueryController":  "Information"
        }
    },
    "AllowedHosts": "*"
}

Once you've got the configuration set, just run the API project in your Development environment and test with the included Swagger UI.

GET /api/Tables or /api/{database}/Tables endpoint to list the tables in the database. The response will look like:

[
  {
    "TABLE_NAME": "DimDate"
  },
  {
    "TABLE_NAME": "DimProduct"
  },
  {
    "TABLE_NAME": "DimProductCategory"
  },
  {
    "TABLE_NAME": "DimProductSubcategory"
  },
  {
    "TABLE_NAME": "FactInternetSales"
  }
]

GET the /api/Tables/{tableName} or /api/{database}/Tables/{tableName} endpoint to dump the contents of a table.

GET or POST the /api/Query of /api/{database}/Query endpoint to run an arbitrary DAX query. A handy bit of DAX to know is the evaluate statement: https://docs.microsoft.com/en-us/dax/evaluate-statement-dax, eg:

evaluate(DimProduct)

to query an entire table. And instead of writing DAX by hand, you use the Perofrmance Analyzer in Power BI desktop to see the DAX queries sent by a Power BI report. https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-performance-analyzer

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

azure-analysis-services-http-sample's People

Contributors

davidbaxterbrowne avatar dbrownems avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar rudywkm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

azure-analysis-services-http-sample's Issues

XMLA end Point connection with Node/Angular Js

Hi There,

I am using PBI rest API to pull the data from PBI dataset but is there any scope ? if we can get the PBI dataSet using Angular/Node Js with XMLA end point connection way.

PowerBI Rest API has limitation as given the link above while executing the DAX Queries we encountered error like

Status 400 - Failed to execute the DAX queries
Status 500 - An error has occurred

However on running these queries in DAX studio or if we re run in webApp that give the result.

Http 500 Internal server error

I am getting that error when trying running the tests.

In the API side I got authentication failed, but user, password, etc are ok.

Any idea?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.