You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Authentication and authorization for Azure Time Series Insights API
18
18
19
19
This document describes how to register an app in Azure Active Directory using the new Azure Active Directory blade. Apps registered in Azure Active Directory enable users to authenticate to and be authorized to use the Azure Time Series Insight API associated with a Time Series Insights environment.
20
20
21
+
> [!IMPORTANT]
22
+
> Azure Time Series Insights supports both of the following authentication libraries:
23
+
> * The more recent [Microsoft Authentication Library (MSAL)](https://docs.microsoft.com/azure/active-directory/develop/msal-overview)
24
+
> * The [Azure Active Directory Authentication Library (ADAL)](https://docs.microsoft.com/azure/active-directory/develop/active-directory-authentication-libraries)
25
+
21
26
## Service principal
22
27
23
28
The following sections describe how to configure an application to access the Time Series Insights API on behalf of an app. The application may then query or publish reference data in the Time Series Insights environment using its own application credentials through Azure Active Directory.
@@ -71,30 +76,19 @@ Per **step 3**, separating your application's and your user credentials allows y
71
76
72
77
### Client app initialization
73
78
74
-
1. Use the **Application ID** and **Client Secret** (Application Key) from the Azure Active Directory app registration section to acquire the token on behalf of the application.
79
+
* Developers may use the [Microsoft Authentication Library (MSAL)](https://docs.microsoft.com/azure/active-directory/develop/msal-overview) or [Azure Active Directory Authentication Library (ADAL)](https://docs.microsoft.com/azure/active-directory/develop/active-directory-authentication-libraries) to authenticate with Azure Time Series Insights.
75
80
76
-
In C#, the following code can acquire the token on behalf of the application. For a complete sample, see [Query data using C#](time-series-insights-query-data-csharp.md).
1. Use the **Application ID** and **Client Secret** (Application Key) from the Azure Active Directory app registration section to acquire the token on behalf of the application.
// Set the resource URI to the Azure Time Series Insights API
87
-
resource: "https://api.timeseries.azure.com/",
88
-
clientCredential: newClientCredential(
89
-
// Application ID of application registered in Azure Active Directory
90
-
clientId: "YOUR_APPLICATION_ID",
91
-
// Application key of the application that's registered in Azure Active Directory
92
-
clientSecret: "YOUR_CLIENT_APPLICATION_KEY"));
85
+
1. In C#, the following code can acquire the token on behalf of the application. For a complete sample, see [Query data using C#](time-series-insights-query-data-csharp.md).
1. The token can then be passed in the `Authorization` header when the application calls the Time Series Insights API.
90
+
91
+
* Alternatively, developers may choose to authenticate using MSAL. Read about [migrating to MSAL](https://docs.microsoft.com/azure/active-directory/develop/msal-net-migration) to learn more.
98
92
99
93
## Common headers and parameters
100
94
@@ -106,39 +100,57 @@ To perform authenticated queries against the [Time Series Insights REST APIs](ht
106
100
107
101
> [!IMPORTANT]
108
102
> The token must be issued exactly to the `https://api.timeseries.azure.com/` resource (also known as the "audience" of the token).
109
-
>*Your [Postman](https://www.getpostman.com/) **AuthURL** with therefore conform to: `https://login.microsoftonline.com/microsoft.onmicrosoft.com/oauth2/authorize?resource=https://api.timeseries.azure.com/`
103
+
> * Your [Postman](https://www.getpostman.com/)**AuthURL**will therefore be: `https://login.microsoftonline.com/microsoft.onmicrosoft.com/oauth2/authorize?resource=https://api.timeseries.azure.com/`
110
104
111
105
> [!TIP]
112
106
> See the hosted Azure Time Series Insights [client SDK sample visualization](https://tsiclientsample.azurewebsites.net/) to see how to authenticate with the Time Series Insights APIs programmatically using the [JavaScript Client SDK](https://github.com/microsoft/tsiclient/blob/master/docs/API.md) along with charts and graphs.
113
107
114
108
### HTTP headers
115
109
116
-
Requiredrequestheaders:
110
+
Required request headers are described below.
117
111
118
-
- `Authorization` forauthenticationandauthorization, avalidOAuth2.0BearertokenmustbepassedintheAuthorizationheader. Thetokenmustbeissuedexactlytothe `https://api.timeseries.azure.com/` resource (also known as the "audience" of the token).
112
+
| Required request header | Description |
113
+
| --- | --- |
114
+
| Authorization | To authenticate with Time Series Insights, a valid OAuth 2.0 Bearer token must be passed in the **Authorization** header. |
119
115
120
-
Optionalrequestheaders:
116
+
> [!IMPORTANT]
117
+
> * The token must be issued exactly to `https://api.timeseries.azure.com/` (which is known as the "audience" of the token).
118
+
> * Note that `https://api.timeseries.azure.com/` is valid but `https://api.timeseries.azure.com` is not.
| Content-type | only `application/json` is supported. |
125
+
| x-ms-client-request-id | A client request ID. The service records this value. Allows the service to trace operation across services. |
126
+
| x-ms-client-session-id | A client session ID. The service records this value. Allows the service to trace a group of related operations across services. |
127
+
| x-ms-client-application-name | Name of the application that generated this request. The service records this value. |
Optional but recommended response headers are described below.
130
+
131
+
| Response header | Description |
132
+
| --- | --- |
133
+
| Content-type | Only `application/json` is supported. |
134
+
| x-ms-request-id | Server-generated request ID. Can be used to contact Microsoft to investigate a request. |
131
135
132
136
### HTTP parameters
133
137
134
-
RequiredURLquerystringparameters:
138
+
Required URL query string parameters depend on API version.
139
+
140
+
| Release | Possible API version values |
141
+
| --- | --- |
142
+
| General Availability |`api-version=2016-12-12`|
143
+
| Preview |`api-version=2018-11-01-preview`|
144
+
| Preview |`api-version=2018-08-15-preview`|
135
145
136
-
- `api-version=2016-12-12`
137
-
- `api-version=2018-11-01-preview`
146
+
> [!TIP]
147
+
> The required API query value to use for each API is given in the [reference documentation](https://docs.microsoft.com/rest/api/time-series-insights/).
138
148
139
-
OptionalURLquerystringparameters:
149
+
Optional URL query string parameters include setting a timeout for HTTP request execution times.
140
150
141
-
- `timeout=<timeout>` – server-sidetimeoutfortherequestexecution. Applicableonlytothe [GetEnvironmentEvents](https://docs.microsoft.com/rest/api/time-series-insights/ga-query-api#get-environment-events-api) and [Get Environment Aggregates](https://docs.microsoft.com/rest/api/time-series-insights/ga-query-api#get-environment-aggregates-api) APIs. Timeout value should be in ISO 8601 duration format, for example `"PT20S"` and should be in the range `1-30 s`. Default value is `30 s`.
151
+
| Optional query parameter | Description |
152
+
| --- | --- |
153
+
|`timeout=<timeout>`| Server-side timeout for HTTP request execution. Applicable only to the [Get Environment Events](https://docs.microsoft.com/rest/api/time-series-insights/ga-query-api#get-environment-events-api) and [Get Environment Aggregates](https://docs.microsoft.com/rest/api/time-series-insights/ga-query-api#get-environment-aggregates-api) APIs. Timeout value should be in ISO 8601 duration format, for example `"PT20S"` and should be in the range `1-30 s`. Default value is `30 s`. |
0 commit comments