共用方式為


資料資產 (Azure 資料目錄 REST API)

標註

標注資產。

etag 屬性是選擇性的,用於並行控制。

POST https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}/{nested_view_name}?api-version={api-version}

注意

某些 HTTP 用戶端實作可能會自動重新發出要求,以回應來自伺服器的 302,但通常會從要求移除 授權標頭 。 由於需要 Authorization 標頭才能對 ADC 提出要求,因此您必須確保將要求重新發出至 ADC 所指定的重新導向位置時,仍會提供 Authorization 標頭。 以下是使用 .NET HttpWebRequest 物件示範此範例的程式碼。

URI 參數

名稱 描述 資料類型
catalog_name 目錄的名稱,或 「DefaultCatalog」 以使用預設目錄。 String
view_name 資料資產檢視的名稱。 String
view_item_id 檢視專案的識別碼。 String
nested_view_name 巢狀檢視專案的名稱。 String
api-version API 版本。 String

範例:新增專家

POST https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0...1be45ecd462a/experts?api-version=2016-03-30
Content-Type: application/json
x-ms-client-request-id:   13d9f885…a92d-8a9f8cf9f707
Authorization: Bearer eyJ0eX ... FWSXfwtQ

主體

{
    "etag": "59085E253E2244A59F664A2F447E675E",
    "properties":
    {
        "fromSourceSystem": false,
        "key": "22c3fa019b3945dc97143ebc3ad74cbf--1111fa019b3945dc97143ebc3ad74cbf",
        "expert":
        {
            "upn": "expert1@contoso.com",
            "objectId": "1111fa019b3945dc97143ebc3ad74cbf"
        },
    }
}

範例:新增詞彙詞彙標籤

POST https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0...1be45ecd462a/termTags?api-version=2016-03-30

標頭

Content-Type: application/json
x-ms-client-request-id:   13d9f885…a92d-8a9f8cf9f707
Authorization: Bearer eyJ0eX ... FWSXfwtQ

主體

{
    "etag": "59085E253E2244A59F664A2F447E675E",
    "properties":
    {
        "fromSourceSystem": false,
        "key": "22c3fa019b3945dc97143ebc3ad74cbf--1111fa019b3945dc97143ebc3ad74cbf",
        "termId": "https://test.catalog.com/catalogs/DefaultCatalog/glossaries/DefaultGlossary/terms/ed975c9d-2fb2-49a3-b6f2-222389cefd7e",
    }
}

範例:新增詞彙欄字詞標籤

POST https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0...1be45ecd462a/columnTermTags?api-version=2016-03-30

標頭

Content-Type: application/json
x-ms-client-request-id:   13d9f885…a92d-8a9f8cf9f707
Authorization: Bearer eyJ0eX ... FWSXfwtQ

主體

{
    "etag": "59085E253E2244A59F664A2F447E675E",
    "properties":
    {
        "fromSourceSystem": false,
        "key": "22c3fa019b3945dc97143ebc3ad74cbf--1111fa019b3945dc97143ebc3ad74cbf",
        "columnName": "Col1",
        "termId": "https://test.catalog.com/catalogs/DefaultCatalog/glossaries/DefaultGlossary/terms/ed975c9d-2fb2-49a3-b6f2-222389cefd7e",
    }
}

回應

狀態碼

程式碼 描述
201 已建立。 要求已完成,並已建立新的批註。
200 正常。 已更新現有的批註。
412 前置條件失敗。 因為至少一個專案中的 ETag 不符,所以要求已取消。

Content-Type

application/json

標頭

HTTP/1.1 201 Created
x-ms-request-id: 72cf83c0…058f2b2a0c68
Location: https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0...1be45ecd462a/experts/22c3fa019b3945dc97143ebc3ad74cbf-1111fa019b3945dc97143ebc3ad74cbf

註冊或更新

如果具有相同身分識別的資產已經存在,請註冊新的資料資產或更新現有的資產。 專案可以選擇性地包含 ETag 值,以為其啟用開放式平行存取控制。

GitHub 上的開始使用範例

要求

POST https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}?api-version={api-version}  

注意

某些 HTTP 用戶端實作可能會自動重新發出要求,以回應來自伺服器的 302,但通常會從要求移除授權標頭。 由於需要 Authorization 標頭才能對 ADC 提出要求,因此您必須確保將要求重新發出至 ADC 所指定的重新導向位置時,仍會提供 Authorization 標頭。 以下是使用 .NET HttpWebRequest 物件示範此範例的程式碼。

URI 參數

名稱 描述 資料類型
catalog_name 目錄的名稱,或 「DefaultCatalog」 以使用預設目錄。 String
view_name 資料資產檢視的名稱。 String
api-version API 版本。 String

POST 範例

POST https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables?api-version=2016-03-30  

標頭

Content-Type: application/json    
x-ms-client-request-id: 13c45c14…46ab469473f0    
Authorization: Bearer eyJ0eX ... FWSXfwtQ

本文範例

{  
    "roles": [  
        {  
            "role": "Contributor",  
            "members": [  
                {  
                    "objectId": "00000000-0000-0000-0000-000000000201"  
                }  
            ]  
        }  
    ],  
    "properties": {  
        "fromSourceSystem": true,  
        "name": "Orders",  
        "dataSource": {  
            "sourceType": "SQL Server",  
            "objectType": "Table"  
        },  
        "dsl": {  
            "protocol": "tds",  
            "authentication": "windows",  
            "address": {  
                "server": "MyServer.contoso.com",  
                "database": "NORTHWND",  
                "schema": "dbo",  
                "object": "Orders"  
            }  
        },  
        "lastRegisteredBy": {  
            "upn": "user1@contoso.com",  
            "firstName": "User1FirstName",  
            "lastName": "User1LastName"  
        },  
        "containerId": "containers/3b2c00be-...-1f15367f54e4"  
    },  
    "annotations": {  
        "schema": {  
            "roles": [  
                {  
                    "role": "Contributor",  
                    "members": [  
                        {  
                            "objectId": "00000000-0000-0000-0000-000000000201"  
                        }  
                    ]  
                }  
            ],  
            "properties": {  
                "fromSourceSystem": true,  
                "columns": [  
                    {  
                        "name": "OrderID",  
                        "isNullable": false,  
                        "type": "int",  
                        "maxLength": 4,  
                        "precision": 10  
                    },  
                    {  
                        "name": "CustomerID",  
                        "isNullable": true,  
                        "type": "nchar",  
                        "maxLength": 10,  
                        "precision": 0  
                    },  
                    {  
                        "name": "EmployeeID",  
                        "isNullable": true,  
                        "type": "int",  
                        "maxLength": 4,  
                        "precision": 10  
                    },  
                    {  
                        "name": "OrderDate",  
                        "isNullable": true,  
                        "type": "datetime",  
                        "maxLength": 8,  
                        "precision": 23  
                    }  
                ]  
            }  
        }  
    }  
}  

回應

狀態碼

程式碼 描述
200 正常。 已更新現有的資產。
201 已建立。 要求已完成,並已建立新的資產。
412 前置條件失敗。 因為至少一個專案中的 ETag 不符,所以要求已取消。

Content-Type

application/json

標頭

HTTP/1.1 201 Created  
x-ms-request-id: 72cf83c0…058f2b2a0c68  
Location: https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/tables/042297b0…1be45ecd462a  

支援的資料來源

如需目前支援的資料來源物件清單,請參閱Azure 資料目錄支援的資料來源。

範例

此範例示範如何取得 Azure AD 存取權杖,並執行 註冊 作業。

注意 此範例會使用 DefaultCatalog 關鍵字來更新使用者的預設目錄。 您也可以指定實際的目錄名稱。 若要尋找目錄名稱,請登入Azure 資料目錄,然後選擇 [使用者]。 您會看到 目錄 名稱。

using System;  
using System.Net;  
using Microsoft.IdentityModel.Clients.ActiveDirectory;  
using System.IO;  

...  

//To learn how to register a client app and get a Client ID,  
// see https://msdn.microsoft.com/library/azure/mt403303.aspx#clientID  
static string clientIDFromAzureAppRegistration = "{clientID}";  

static void Main(string[] args)  
{  
    //Note: This example uses the "DefaultCatalog" keyword to update the user's default catalog.  You may alternately  
    //specify the actual catalog name.  
    string catalogName = "DefaultCatalog";  

    string registerJson = Register(catalogName, OrdersJsonWithEveryoneContributor());  

    Console.ReadLine();  
}  

static AuthenticationResult AccessToken()  
{  
    //Get access token:  
    // To call a Data Catalog REST operation, create an instance of AuthenticationContext and call AcquireToken  
    // AuthenticationContext is part of the Active Directory Authentication Library NuGet package  
    // To install the Active Directory Authentication Library NuGet package in Visual Studio,  
    //  run "Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory" from the nuget Package Manager Console.  

    //Resource Uri for Data Catalog API  
    string resourceUri = "https://api.azuredatacatalog.com";  

    //To learn how to register a client app and get a Client ID, see https://msdn.microsoft.com/library/azure/mt403303.aspx#clientID     
    string clientId = clientIDFromAzureAppRegistration;  

    //A redirect uri gives AAD more details about the specific application that it will authenticate.  
    //Since a client app does not have an external service to redirect to, this Uri is the standard placeholder for a client app.  
    string redirectUri = "https://login.live.com/oauth20_desktop.srf";  

    // Create an instance of AuthenticationContext to acquire an Azure access token  
    // OAuth2 authority Uri  
    string authorityUri = "https://login.windows.net/common/oauth2/authorize";  
    AuthenticationContext authContext = new AuthenticationContext(authorityUri);  

    // Call AcquireToken to get an Azure token from Azure Active Directory token issuance endpoint  
    //  AcquireToken takes a Client Id that Azure AD creates when you register your client app.  
    return authContext.AcquireToken(resourceUri, clientId, new Uri(redirectUri), PromptBehavior.RefreshSession);  
}  

static string Register(string catalogName, string json)  
{  
    string location = string.Empty;  
    string fullUri = string.Format("https://api.azuredatacatalog.com/catalogs/{0}/views/{1}?api-version=2016-03-30", catalogName, viewType);  

    //Create a POST WebRequest as a Json content type  
    HttpWebRequest request = System.Net.WebRequest.Create(fullUri) as System.Net.HttpWebRequest;  
    request.KeepAlive = true;  
    request.Method = "POST";  
    try  
    {  
        var response = SetRequestAndGetResponse(request, json);  

        //Get the Response header which contains the data asset ID  
        //The format is: tables/{data asset ID}  
        location = httpWebResponse.Headers["Location"];  
    }  
    catch (WebException ex)  
    {  
        Console.WriteLine(ex.Message);  
        Console.WriteLine(ex.Status);  
        if (ex.Response != null)  
        {  
            // can use ex.Response.Status, .StatusDescription  
            if (ex.Response.ContentLength != 0)  
            {  
                using (var stream = ex.Response.GetResponseStream())  
                {  
                    using (var reader = new StreamReader(stream))  
                    {  
                        Console.WriteLine(reader.ReadToEnd());  
                    }  
                }  
            }  
        }  
        location = null;  
    }  
    return location;  
}  

static HttpWebResponse SetRequestAndGetResponse(HttpWebRequest request, string payload = null)  
{  
    while (true)  
    {  
        //To authorize the operation call, you need an access token which is part of the Authorization header  
        request.Headers.Add("Authorization", AccessToken().CreateAuthorizationHeader());  
        //Set to false to be able to intercept redirects  
        request.AllowAutoRedirect = false;  

        if (!string.IsNullOrEmpty(payload))  
        {  
            byte[] byteArray = Encoding.UTF8.GetBytes(payload);  
            request.ContentLength = byteArray.Length;  
            request.ContentType = "application/json";  
            //Write JSON byte[] into a Stream  
            request.GetRequestStream().Write(byteArray, 0, byteArray.Length);  
        }  
        else  
        {  
            request.ContentLength = 0;  
        }  

        HttpWebResponse response = request.GetResponse() as HttpWebResponse;  

        // Requests to **Azure Data Catalog (ADC)** may return an HTTP 302 response to indicate  
        // redirection to a different endpoint. In response to a 302, the caller must re-issue  
        // the request to the URL specified by the Location response header.  
        if (response.StatusCode == HttpStatusCode.Redirect)  
        {  
            string redirectedUrl = response.Headers["Location"];  
            HttpWebRequest nextRequest = WebRequest.Create(redirectedUrl) as HttpWebRequest;  
            nextRequest.Method = request.Method;  
            request = nextRequest;  
        }  
        else  
        {  
            return response;  
            break;  
        }  
    }  
}  

static string OrdersJsonWithEveryoneContributor()  
{  
    return @"  
    {  
        'roles': [  
            {  
                'role': 'Contributor',  
                'members': [  
                    {  
                        'objectId': '00000000-0000-0000-0000-000000000201'  
                    }  
                ]  
            }  
        ],  
        'properties': {  
            'fromSourceSystem': 'true',  
            'name': 'Orders',  
            'dataSource': {  
                'sourceType': 'SQL Server',  
                'objectType': 'Table'  
            },  
            'dsl': {  
                'protocol': 'tds',  
                'authentication': 'windows',  
                'address': {  
                    'server': 'MyServer.contoso.com',  
                    'database': 'NORTHWND',  
                    'schema': 'dbo',  
                    'object': 'Orders'  
                }  
            },  
            'lastRegisteredBy': {  
                'upn': 'user1@contoso.com',  
                'firstName': 'User1FirstName',  
                'lastName': 'User1LastName'  
            },  
            'containerId': 'containers/a9f8a2e1-d826-7c0c-b186-c7f4334a6b4f'  
        },  
        'annotations': {  
            'schema': {  
                'roles': [  
                    {  
                        'role': 'Contributor',  
                        'members': [  
                            {  
                                'objectId': '00000000-0000-0000-0000-000000000201'  
                            }  
                        ]  
                    }  
                ],  
                'properties': {  
                    'fromSourceSystem': 'true',  
                    'columns': [  
                        {  
                            'name': 'OrderID',  
                            'isNullable': false,  
                            'type': 'int',  
                            'maxLength': 4,  
                            'precision': 10  
                        },  
                        {  
                            'name': 'CustomerID',  
                            'isNullable': true,  
                            'type': 'nchar',  
                            'maxLength': 10,  
                            'precision': 0  
                        },  
                        {  
                            'name': 'EmployeeID',  
                            'isNullable': true,  
                            'type': 'int',  
                            'maxLength': 4,  
                            'precision': 10  
                        },  
                        {  
                            'name': 'OrderDate',  
                            'isNullable': true,  
                            'type': 'datetime',  
                            'maxLength': 8,  
                            'precision': 23  
                        }  
                    ]  
                }  
            }  
        }  
    }";  
}  

取得附注

取得具有批註的資料資產。

它支援選擇性的 Accept 標頭參數 adc.metadata ,要求 ETag 包含在所有專案的回應中。 使用最小值或完整值來取得 ETag 以回應。 有效值為 noneminimalfull

要求

GET https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}?api-version={api-version}  

注意

某些 HTTP 用戶端實作可能會自動重新發出要求,以回應來自伺服器的 302,但通常會從要求移除 授權標頭 。 由於需要 Authorization 標頭才能對 ADC 提出要求,因此您必須確保將要求重新發出至 ADC 所指定的重新導向位置時,仍會提供 Authorization 標頭。 以下是使用 .NET HttpWebRequest 物件示範此範例的程式碼。

URI 參數

名稱 描述 資料類型
catalog_name 目錄的名稱,或 「DefaultCatalog」 以使用預設目錄。 String
view_name 資料資產檢視的名稱。 String
view_item_id 檢視專案的識別碼。 String
api-version API 版本。 String

GET 範例

GET https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b...1be45ecd462a?api-version=2016-03-30  

標頭

x-ms-client-request-id: 8091955f…8f5b4c0acede    
Authorization:  Bearer eXJ0eyAiOiJKV1QiLCJhbGciOi...    
Accept: application/json;adc.metadata=full  

回應

狀態碼

程式碼 描述
200 正常。 回應包含要求的資產檢視。

Content-Type

application/json

標頭

x-ms-request-id: 1095e88c…caffabd6dabd  
Content-Type:   application/json; charset=utf-8

主體

{  
    "id": "https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/tables/042297b0-...-1be45ecd462a",  
    "etag": "1234567891",  
    "timestamp": "2015-05-15T03:48:39.2425547",  
    "roles": [  
        {  
            "role": "Contributor",  
            "members": [  
                {  
                    "objectId": "00000000-0000-0000-0000-000000000201"  
                }  
            ]  
        }  
    ],  
    "effectiveRights": [  
        "Read",  
        "Delete",  
        "ChangeOwnership",  
        "ChangeVisibility",  
        "ViewPermissions",  
        "ViewRoles",  
        "Update",  
        "TakeOwnership"  
    ],  
    "properties": {  
        "fromSourceSystem": true,  
    "name": "Orders",  
    "dataSource": {  
        "sourceType": "SQL Server",  
            "objectType": "Table"  
    },  
    "dsl": {  
        "protocol": "tds",  
        "authentication": "windows",  
        "address": {  
            "server": "MyServer.contoso.com",  
            "database": "NORTHWND",  
            "schema": "dbo",  
            "object": "Orders"  
        }  
    },  
    "lastRegisteredBy": {  
        "upn": "user1@contoso.com",  
        "firstName": "User1FirstName",  
        "lastName": "User1LastName"  
    },  
        "containerId": "containers/3b2c00be-...-1f15367f54e4"  
    },  
    "annotations": {  
        "schema": {  
            "id": "https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/tables/042297b0-...-1be45ecd462a/schema",  
            "etag": "1234567892",  
            "timestamp": "2015-05-15T03:48:39.2425547",  
            "roles": [  
                {  
                    "role": "Contributor",  
                    "members": [  
        {  
                            "objectId": "00000000-0000-0000-0000-000000000201"  
                        }  
                    ]  
                }  
            ],  
            "effectiveRights": [  
                    "Read",  
                    "Delete",  
                    "ViewRoles",  
                    "Update"  
                ],  
            "properties": {  
                "fromSourceSystem": true,  
            "columns": [  
                {  
                    "name": "OrderID",  
                    "isNullable": false,  
                    "type": "int",  
                    "maxLength": 4,  
                    "precision": 10  
                },  
                {  
                    "name": "CustomerID",  
                    "isNullable": true,  
                    "type": "nchar",  
                    "maxLength": 10,  
                    "precision": 0  
                },  
                {  
                    "name": "EmployeeID",  
                    "isNullable": true,  
                    "type": "int",  
                    "maxLength": 4,  
                    "precision": 10  
                },  
                {  
                    "name": "OrderDate",  
                    "isNullable": true,  
                    "type": "datetime",  
                    "maxLength": 8,  
                    "precision": 23  
                }  
                ]  
        }  
        },  
    "experts": [  
        {  
                "id": "https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/tables/042297b0-...-1be45ecd462a/experts/22c3fa019b3945dc97143ebc3ad74cbf-1111fa019b3945dc97143ebc3ad74cbf",  
                "etag": "1234567893",  
                "timestamp": "2015-05-15T03:48:39.2425547",  
                "roles": [  
                    {  
                        "role": "Contributor",  
                        "members": [  
                            {  
                                "objectId": "22c3fa01-9b39-45dc-9714-3ebc3ad74cbf"  
                            }  
                        ]  
                    }  
                ],  
                "effectiveRights": [  
                    "Read",  
                    "Delete",  
                    "ViewRoles",  
                    "Update"  
                ],  
                "properties": {  
                    "fromSourceSystem": false,  
                    "key": "22c3fa019b3945dc97143ebc3ad74cbf-1111fa019b3945dc97143ebc3ad74cbf",  
                    "expert": {  
                        "upn": "expert1@contoso.com",  
                        "objectId": "1111fa019b3945dc97143ebc3ad74cbf"  
                    }  
                }  
        }  
    ]  
}  
}

根據提供的搜尋字詞搜尋資料資產。

要求

GET https://api.azuredatacatalog.com/catalogs/{catalog_name}/search/search?api-version={api-version}&searchTerms={search_terms}&facets={facet_terms}&startPage={start_page}&count={count}&view={data_source}  

注意

某些 HTTP 用戶端實作可能會自動重新發出要求,以回應來自伺服器的 302,但通常會從要求移除 授權標頭 。 由於需要 Authorization 標頭才能對 ADC 提出要求,因此您必須確保將要求重新發出至 ADC 所指定的重新導向位置時,仍會提供 Authorization 標頭。 以下是使用 .NET HttpWebRequest 物件示範此範例的程式碼。

URI 參數

名稱 描述 資料類型
catalog_name 目錄的名稱,或 「DefaultCatalog」 以使用預設目錄。 String
api-version API 版本。 String

查詢參數

名稱 描述 資料類型
searchTerms 必要。 要搜尋的字詞。 String
facet 選擇性 的逗號分隔功能變數名稱,用於對結果進行 Facet。 String
startPage 用於分頁之結果的選擇性起始頁,以及 count 參數。 允許的值大於 0,如果傳遞小於或等於 0 的值,則會傳回錯誤碼為 400 的 HTTP 錯誤。 String
count 選擇性 單頁 (分頁) 中想要的結果數目。 預設值是 10。 允許的值間隔介於 1 到 100 之間。 如果傳遞超出此範圍的值,則會傳回錯誤碼為 400 的 HTTP 錯誤。 若要取得搜尋結果的下一個部分,請重複要求,但增加 startPage 1。 整數
檢視 選擇性 取得用戶端想要查看的檢視,目前為 DataSource 中唯一支援的選項。 String

GET 範例

https://api.azuredatacatalog.com/catalogs/DefaultCatalog/search/search?searchTerms=My_Server&count=10&startPage=1&api-version=2016-03-30

標頭

x-ms-client-request-id: 546f053a…a1612f3a3d69  
Authorization:  Bearer eXJ0eyAiOiJKV1QiLCJhbGciOi...  

回應

狀態碼

程式碼 描述
200 正常。 具有搜尋結果的成功作業。

Content-Type

application/json

標頭

x-ms-request-id: 0ab2e798…088223257ad2  
Content-Length:  3926

主體

{  
"query": {  
    "id": "bd067219...4ba9a56e204b",  
    "searchTerms": "My_server",  
    "startIndex": 1,  
    "startPage": 1,  
    "count": 1,  
    "id": "bd067219...4ba9a56e204b",  
    "totalResults": 508,  
    "startIndex": 1,  
    "itemsPerPage": 1,  
    "results": [{  
    "updated": "0001-01-01T00:00:00",  
    "content": {  
          "properties": {  
            "fromSourceSystem": true,  
            "name": "MyTable",  
            "dsl": {  
              "protocol": "tds",  
              "authentication": "windows",  
              "address": {  
                "server": "My_SERVER",  
                "database": "my_DB",  
                "schema": "my_SCHEMA",  
                "object": "my_TABLE"  
              }  
            },  
            "dataSource": {  
              "sourceType": "SQL Server",  
              "objectType": "Table"  
            },  
            "lastRegisteredBy": {  
              "upn": "user1@contoso.com",  
              "firstName": "User1FirstName",  
              "lastName": "User1LastName"  
            },  
            "containerId": "https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/containers/a9f8a2e1-d826-7c0c-b186-c7f4334a6b4f"  
          },  
          "id": "https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/tables/08d91f0d-26a0-1e8e-ab3b-d463ac3e62cb",  
          "type": "Microsoft.DataSource.Table.1",  
          "timestamp": "2016-03-15T23:20:12.5423855",  
          "annotations": {  
            "schema": {  
              "properties": {  
                "fromSourceSystem": true,  
                "columns": [  
                  {  
                    "name": "ID",  
                    "type": "int",  
                    "maxLength": 4,  
                    "precision": 10,  
                    "isNullable": false  
                  },  
                  {  
                    "name": "Column2",  
                    "type": "nchar",  
                    "maxLength": 10,  
                    "precision": 0,  
                    "isNullable": true  
                  }  
                ]  
              },  
              "id": "https://e2255231-6dd3-1a0d-a6d8-7fc96dd780c2-mycatalog.api.azuredatacatalog.com/catalogs/MyCatalog/views/tables/08d91f0d-26a0-1e8e-ab3b-d463ac3e62cb/schema",  
              "type": "Microsoft.DataSource.Schema.1",  
              "timestamp": "2016-03-15T23:20:12.5423855",  
              "roles": [  
                {  
                  "role": "Contributor",  
                  "members": [  
                    {  
                      "objectId": "00000000-0000-0000-0000-000000000201"  
                    }  
                  ]  
                }  
              ],  
              "effectiveRights": [  
                "Read",  
                "Delete",  
                "ViewRoles",  
                "Update"  
              ]  
            }  
          },  
          "roles": [  
            {  
              "role": "Contributor",  
              "members": [  
                {  
                  "objectId": "00000000-0000-0000-0000-000000000201"  
                }  
              ]  
            }  
          ],  
          "effectiveRights": [  
            "Read",  
            "Delete",  
            "ChangeOwnership",  
            "ChangeVisibility",  
            "ViewPermissions",  
            "ViewRoles",  
            "Update",  
            "TakeOwnership"  
          ]  
        },  
    "hitProperties": [{  
        "fieldPath": "properties.dsl.address.server",  
        "highlightDetail": [{  
            "highlightedWords": [{  
                "word": "My_sERVER"  
            }],  
            "highlightedFragment": "My_sERVER"  
        }]  
    },  
    {  
        "fieldPath": "properties.dataSource.sourceType",  
        "highlightDetail": [{  
            "highlightedWords": [{  
                "word": "Server"  
            }],  
            "highlightedFragment": "SQL Server"  
        }]  
    },  
    {  
        "fieldPath": "properties.dsl.address.object",  
        "highlightDetail": [{  
            "highlightedWords": [{  
                "word": "my"  
            }],  
            "highlightedFragment": "my_TABLE"  
        }]  
    },  
    {  
        "fieldPath": "properties.dsl.address.database",  
        "highlightDetail": [{  
            "highlightedWords": [{  
                "word": "my"  
            }],  
            "highlightedFragment": "my_DB"  
        }]  
    },  
    {  
        "fieldPath": "properties.dsl.address.schema",  
        "highlightDetail": [{  
            "highlightedWords": [{  
                "word": "my"  
            }],  
            "highlightedFragment": "my_SCHEMA"  
        }]  
    }]  
}]  
}

範例

此範例示範如何取得 Azure AD 存取權杖,並執行 搜尋 作業。

注意若要尋找目錄名稱,請登入Azure 資料目錄,然後選擇 [使用者]。 您會看到 目錄 名稱。

using System;  
using System.Net;  
using Microsoft.IdentityModel.Clients.ActiveDirectory;  
using System.IO;  

...  

//To learn how to register a client app and get a Client ID,  
// see https://msdn.microsoft.com/library/azure/mt403303.aspx#clientID  
static string clientIDFromAzureAppRegistration = "{clientID}";  

static void Main(string[] args)  
{  
    //Note: This example uses the "DefaultCatalog" keyword to update the user's default catalog.  You may alternately  
    //specify the actual catalog name.  
    string catalogName = "DefaultCatalog";  

    //Search everything  
    string searchTerm = string.Empty;  

    string searchJson = Search(catalogName, searchTerm);  
    //Other examples "tags:=Sales", "upn:{username}"  

    Console.WriteLine(searchJson);  
}  

static AuthenticationResult AccessToken()  
{  
    //Get access token:  
    // To call a Data Catalog REST operation, create an instance of AuthenticationContext and call AcquireToken  
    // AuthenticationContext is part of the Active Directory Authentication Library NuGet package  
    // To install the Active Directory Authentication Library NuGet package in Visual Studio,  
    //  run "Install-Package Microsoft.IdentityModel.Clients.ActiveDirectory" from the nuget Package Manager Console.  

    //Resource Uri for Data Catalog API  
    string resourceUri = "https://api.azuredatacatalog.com";  

    //To learn how to register a client app and get a Client ID, see https://msdn.microsoft.com/library/azure/mt403303.aspx#clientID    
    string clientId = clientIDFromAzureAppRegistration;  

    //A redirect uri gives AAD more details about the specific application that it will authenticate.  
    //Since a client app does not have an external service to redirect to, this Uri is the standard placeholder for a client app.  
    string redirectUri = "https://login.live.com/oauth20_desktop.srf";  

    // Create an instance of AuthenticationContext to acquire an Azure access token  
    // OAuth2 authority Uri  
    string authorityUri = "https://login.windows.net/common/oauth2/authorize";  
    AuthenticationContext authContext = new AuthenticationContext(authorityUri);  

    // Call AcquireToken to get an Azure token from Azure Active Directory token issuance endpoint  
    //  AcquireToken takes a Client Id that Azure AD creates when you register your client app.  
    return authContext.AcquireToken(resourceUri, clientId, new Uri(redirectUri), PromptBehavior.RefreshSession);  
}  

static string Search(string catalogName, string searchTerm)  
{  
    string responseContent = string.Empty;  

    //NOTE: To find the Catalog Name, sign into Azure Data Catalog, and choose User. You will see a list of Catalog names.            
    string fullUri =  
        string.Format("https://api.azuredatacatalog.com/catalogs/{0}/search/search?searchTerms={1}&count=10&api-version=2016-03-30", catalogName, searchTerm);  

    //Create a GET WebRequest  
    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fullUri);  
    request.Method = "GET";  

    try  
    {  
        //Get HttpWebResponse from GET request  
        using (HttpWebResponse httpResponse = SetRequestAndGetResponse(request))  
        {  
            //Get StreamReader that holds the response stream  
            using (StreamReader reader = new System.IO.StreamReader(httpResponse.GetResponseStream()))  
            {  
                responseContent = reader.ReadToEnd();  
            }  
        }  
    }  
    catch (WebException ex)  
    {  
        Console.WriteLine(ex.Message);  
        Console.WriteLine(ex.Status);  
        if (ex.Response != null)  
        {  
            // can use ex.Response.Status, .StatusDescription  
            if (ex.Response.ContentLength != 0)  
            {  
                using (var stream = ex.Response.GetResponseStream())  
                {  
                    using (var reader = new StreamReader(stream))  
                    {  
                        Console.WriteLine(reader.ReadToEnd());  
                    }  
                }  
            }  
        }  
        return null;  
    }  

    return responseContent;  
}  

static HttpWebResponse SetRequestAndGetResponse(HttpWebRequest request, string payload = null)  
{  
    while (true)  
    {  
        //To authorize the operation call, you need an access token which is part of the Authorization header  
        request.Headers.Add("Authorization", AccessToken().CreateAuthorizationHeader());  
        //Set to false to be able to intercept redirects  
        request.AllowAutoRedirect = false;  

        if (!string.IsNullOrEmpty(payload))  
        {  
            byte[] byteArray = Encoding.UTF8.GetBytes(payload);  
            request.ContentLength = byteArray.Length;  
            request.ContentType = "application/json";  
            //Write JSON byte[] into a Stream  
            request.GetRequestStream().Write(byteArray, 0, byteArray.Length);  
        }  
        else  
        {  
            request.ContentLength = 0;  
        }  

        HttpWebResponse response = request.GetResponse() as HttpWebResponse;  

        // Requests to **Azure Data Catalog (ADC)** may return an HTTP 302 response to indicate  
        // redirection to a different endpoint. In response to a 302, the caller must re-issue  
        // the request to the URL specified by the Location response header.    
        if (response.StatusCode == HttpStatusCode.Redirect)  
        {  
            string redirectedUrl = response.Headers["Location"];  
            HttpWebRequest nextRequest = WebRequest.Create(redirectedUrl) as HttpWebRequest;  
            nextRequest.Method = request.Method;  
            request = nextRequest;  
        }  
        else  
        {  
            return response;  
            break;  
        }  
    }  
}

刪除

如果附加任何) ,則會刪除資料資產和所有批註 (。

它支援選擇性 If-Match 標頭來進行開放式並行控制。 僅支援弱式格式,例如 W/「123456789」。

要求

DELETE https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}?api-version={api-version}  

注意

某些 HTTP 用戶端實作可能會自動重新發出要求,以回應來自伺服器的 302,但通常會從要求移除 授權標頭 。 由於需要 Authorization 標頭才能對 ADC 提出要求,因此您必須確保將要求重新發出至 ADC 所指定的重新導向位置時,仍會提供 Authorization 標頭。 以下是使用 .NET HttpWebRequest 物件示範此範例的程式碼。

URI 參數

名稱 描述 資料類型
catalog_name 目錄的名稱,或 「DefaultCatalog」 以使用預設目錄。 String
view_name 資料資產檢視的名稱。 String
view_item_id 檢視專案的識別碼。 String
api-version API 版本。 String

DELETE 範例

DELETE https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0...1be45ecd462a?api-version=2016-03-30

標頭

x-ms-client-request-id: 59b68a46…46dc3ec8dcb8    
Authorization:  Bearer eXJ0eyAiOiJKV1QiLCJhbGciOi...    
If-Match: W/"123456789"  

回應

狀態碼

程式碼 描述
204 NoContent
注意:刪除作業語意為「如果有刪除」,因此如果資產或注釋不存在成功狀態碼 204 (傳回 NoContent) 。
412 前置條件失敗。 因為 ETag 不符,所以要求已取消。

Content-Type

application/json

標頭

x-ms-request-id: 664f86cf…5e512fa78e92  

更新註釋

更新批註。

專案可以選擇性地包含 ETag 值,以為其啟用開放式平行存取控制。

要求

PUT https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}/{nested_view_name}/{nested_non_singleton_view_item_id}?api-version={api-version} 
 
PUT https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}/{nested_view_name}?api-version={api-version}  

注意

某些 HTTP 用戶端實作可能會自動重新發出要求,以回應來自伺服器的 302,但通常會從要求移除 授權標頭 。 由於需要 Authorization 標頭才能對 ADC 提出要求,因此您必須確保將要求重新發出至 ADC 所指定的重新導向位置時,仍會提供 Authorization 標頭。 以下是使用 .NET HttpWebRequest 物件示範此範例的程式碼。

URI 參數

名稱 描述 資料類型
catalog_name 目錄的名稱,或 「DefaultCatalog」 以使用預設目錄。 String
view_name 資料資產檢視的名稱。 String
view_item_id 檢視專案的識別碼。 String
nested_view_name 巢狀檢視的名稱。 String
nested_non_singleton_view_item_id 巢狀非單一檢視專案的識別碼。 必須為非單一檢視提供。 String
api-version API 版本。 String

單一檔檢視的 PUT 範例

PUT https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0...1be45ecd462a/documentation?api-version=2016-03-30

標頭

Content-Type:   application/json; charset=utf-8    
x-ms-client-request-id:   059692ee-...-57490fcec42c    
Authorization:  Bearer eXJ0eyAiOiJKV1QiLCJhbGciOi...  

本文結構描述

Body:  
    {  
        "fromSourceSystem": false,  
        "etag": "123456789",  
        "content": "<new documentation content>",  
        "mimetype": "text",  
    }  

回應

狀態碼

程式碼 描述
200 正常。 已更新現有的批註。
412 前置條件失敗。 因為至少一個專案中的 ETag 不符,所以要求已取消。

Content-Type

application/json

標頭

x-ms-request-id: 3b8668da…1558d0f407c0  

刪除註釋

如果有任何) ,則會刪除批註和所有巢狀注釋 (。

它支援選擇性 If-Match 標頭來進行開放式並行控制。 僅支援弱式格式,例如 W/「123456789」。

要求

DELETE https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}/{nested_view_name}/{nested_non_singleton_view_item_id}?api-version={api-version}  
	
DELETE https://api.azuredatacatalog.com/catalogs/{catalog_name}/views/{view_name}/{view_item_id}/{nested_view_name}?api-version={api-version}  

注意

某些 HTTP 用戶端實作可能會自動重新發出要求,以回應來自伺服器的 302,但通常會從要求移除 授權標頭 。 由於需要 Authorization 標頭才能對 ADC 提出要求,因此您必須確保將要求重新發出至 ADC 所指定的重新導向位置時,仍會提供 Authorization 標頭。 以下是使用 .NET HttpWebRequest 物件示範此範例的程式碼。

URI 參數

名稱 描述 資料類型
catalog_name 目錄的名稱,或 「DefaultCatalog」 以使用預設目錄。 String
view_name 資料資產檢視的名稱。 String
view_item_id 檢視專案的識別碼。 String
nested_view_name 巢狀檢視的名稱。 String
nested_non_singleton_view_item_id 巢狀非單一檢視專案的識別碼。 必須為非單一檢視提供。 String
api-version API 版本。 String

DELETE 範例

DELETE https://api.azuredatacatalog.com/catalogs/DefaultCatalog/views/tables/042297b0-c187-49cc-8f30-1be45ecd462a/experts/22c3fa019b3945dc97143ebc3ad74cbf-1111fa019b3945dc97143ebc3ad74cbf?api-version=2016-03-30  

標頭

x-ms-client-request-id:   c8da5f08…67b203d77b2d  
Authorization:  Bearer eXJ0eyAiOiJKV1QiLCJhbGciOi...  
If-Match: W/"123456789"  

回應

狀態碼

程式碼 描述
204 NoContent
412 前置條件失敗。 因為 ETag 不符,所以要求已取消。

Content-Type

application/json

標頭

x-ms-request-id: 276b9dc4…e5f7017805c