適用于 .NET 的 Azure Purview 共用用戶端程式庫 - 1.0.0-Beta.2 版
Microsoft Purview Share 是完全受控的雲端服務。
請高度依賴 服務的檔 和我們的 通訊協定用戶端檔 ,以使用此程式庫
| 原始程式碼套件 (NuGet) | 產品檔
開始使用
安裝套件
使用 NuGet安裝適用于 .NET 的 Microsoft Purview Share 用戶端程式庫:
dotnet add package Azure.Analytics.Purview.Sharing --prerelease
必要條件
- 您必須擁有 Azure 訂 用帳戶和 Purview 資源 ,才能使用此套件。
驗證用戶端
使用 Azure Active Directory
此範例示範如何使用 DefaultAzureCredential 透過 Azure Active Directory 進行驗證。 不過,將會接受 Azure.Identity 所提供的任何認證。 如需其他認證的詳細資訊,請參閱 Azure.Identity 檔。
選擇並設定認證之後,您就可以建立 的 SentSharesClient
實例。
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var sentShareClient = new SentSharesClient(endPoint, credential);
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var receivedSharesClient = new ReceivedSharesClient(endPoint, credential);
重要概念
通訊協定方法
適用于 .NET 的 Purview 共用用戶端程式庫所公開的作業會使用 通訊協定方法來 公開基礎 REST 作業。 您可以在我們的 檔中深入瞭解如何使用使用通訊協定方法的 Azure SDK 用戶端。
執行緒安全
我們保證所有用戶端實例方法都是安全線程,且彼此獨立 (指導方針) 。 這可確保重複使用用戶端實例的建議一律是安全的,即使是跨執行緒也一樣。
其他概念
用戶端選項 | 存取回應 | 長時間執行的作業 | 處理失敗 | 診斷 | 嘲笑 | 用戶端存留期
範例
下一節說明如何初始化和驗證用戶端和共用資料。
建立已傳送的共用
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var sentShareClient = new SentSharesClient(endPoint, credential);
var data = new
{
shareKind = "InPlace",
properties = new
{
artifact = new
{
storeKind = "AdlsGen2Account",
storeReference = new
{
referenceName = "/subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Storage/storageAccounts/sharerStorageAccount",
type = "ArmResourceReference"
},
properties = new
{
paths = new[]
{
new
{
containerName = "containerName",
senderPath = "senderPath",
receiverPath = "receiverPath"
}
}
}
},
displayName = "displayName",
description = "description",
}
};
Operation<BinaryData> createResponse = await sentShareClient.CreateOrReplaceSentShareAsync(WaitUntil.Completed, "sentShareId", RequestContent.Create(data));
取得已傳送的共用
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var sentShareClient = new SentSharesClient(endPoint, credential);
Response response = await sentShareClient.GetSentShareAsync("sentShareId");
列出已傳送的共用
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var sentShareClient = new SentSharesClient(endPoint, credential);
List<BinaryData> response = await sentShareClient.GetAllSentSharesAsync("referenceName").ToEnumerableAsync();
建立已傳送的共用邀請
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var sentShareClient = new SentSharesClient(endPoint, credential);
var data = new
{
invitationKind = "Service",
properties = new
{
TargetActiveDirectoryId = "targetActiveDirectoryId",
TargetObjectId = "targetObjectId",
}
};
Response response = await sentShareClient.CreateSentShareInvitationAsync("sentShareId", "sentShareInvitationId", RequestContent.Create(data));
取得已傳送的共用邀請
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var sentShareClient = new SentSharesClient(endPoint, credential);
Response response = await sentShareClient.GetSentShareInvitationAsync("sentShareId", "sentShareInvitationId");
列出已傳送的共用邀請
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var sentShareClient = new SentSharesClient(endPoint, credential);
List<BinaryData> sentShareInvitations = await sentShareClient.GetAllSentShareInvitationsAsync("sentShareId").ToEnumerableAsync();
列出已中斷連結的已接收共用
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var receivedSharesClient = new ReceivedSharesClient(endPoint, credential);
List<BinaryData> createResponse = await receivedSharesClient.GetAllDetachedReceivedSharesAsync().ToEnumerableAsync();
建立已接收的共用
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var receivedSharesClient = new ReceivedSharesClient(endPoint, credential);
var data = new
{
shareKind = "InPlace",
properties = new
{
sink = new
{
storeKind = "AdlsGen2Account",
storeReference = new
{
referenceName = "/subscriptions/suscriptionId/resourceGroups/resourceGroup/providers/Microsoft.Storage/storageAccounts/receiverStorageAccount",
type = "ArmResourceReference"
},
properties = new
{
containerName = "containerName",
folder = "folder",
mountPath = "mountPath",
}
},
displayName = "displayName",
}
};
Operation<BinaryData> createResponse = await receivedSharesClient.CreateOrReplaceReceivedShareAsync(WaitUntil.Completed, "receivedShareId", RequestContent.Create(data));
取得已接收的共用
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var receivedSharesClient = new ReceivedSharesClient(endPoint, credential);
Response operation = await receivedSharesClient.GetReceivedShareAsync("receivedShareId");
列出已附加的已接收共用
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var receivedSharesClient = new ReceivedSharesClient(endPoint, credential);
List<BinaryData> createResponse = await receivedSharesClient.GetAllAttachedReceivedSharesAsync("referenceName").ToEnumerableAsync();
刪除已接收的共用
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var receivedSharesClient = new ReceivedSharesClient(endPoint, credential);
Operation operation = await receivedSharesClient.DeleteReceivedShareAsync(WaitUntil.Completed, "receivedShareId");
刪除已傳送的共用邀請
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var sentShareClient = new SentSharesClient(endPoint, credential);
Operation operation = await sentShareClient.DeleteSentShareInvitationAsync(WaitUntil.Completed, "sentShareId", "sentShareInvitationId");
刪除已傳送的共用
var credential = new DefaultAzureCredential();
var endPoint = "https://my-account-name.purview.azure.com/share";
var sentShareClient = new SentSharesClient(endPoint, credential);
Operation operation = await sentShareClient.DeleteSentShareAsync(WaitUntil.Completed, "sentShareId");
疑難排解
設定主控台記錄
查看記錄的最簡單方式是啟用主控台記錄。 若要建立將訊息輸出至主控台的 Azure SDK 記錄接聽程式,請使用 AzureEventSourceListener.CreateConsoleLogger 方法。
// Setup a listener to monitor logged events.
using AzureEventSourceListener listener = AzureEventSourceListener.CreateConsoleLogger();
若要深入瞭解其他記錄機制,請參閱 這裡。
下一步
此用戶端 SDK 會使用 通訊協定方法公開作業,您可以在我們的 檔中深入瞭解如何使用使用通訊協定方法的 SDK 用戶端。
參與
如需建 置 、測試和參與此程式庫的詳細資訊,請參閱 CONTRIBUTING.md。
此專案歡迎參與和提供建議。 大部分的參與都要求您同意「參與者授權合約 (CLA)」,宣告您有權且確實授與我們使用投稿的權利。 如需詳細資訊,請造訪 cla.microsoft.com。
當您提交提取要求時,CLA Bot 會自動判斷您是否需要提供 CLA,並適當地裝飾 PR (例如標籤、註解)。 請遵循 bot 提供的指示。 您只需要使用我們的 CLA 在所有存放庫上執行此動作一次。
此專案採用 Microsoft Open Source Code of Conduct (Microsoft 開放原始碼管理辦法)。 如需詳細資訊,請參閱管理辦法常見問題集,如有任何其他問題或意見請連絡 opencode@microsoft.com。