如何在 Azure Synapse C# 笔记本中安装包?

How to install packages in Azure Synapse C# notebooks?

我需要在 C# 的 Synapse 中使用一些包 运行 notebooks。 运行 下面的片段,我得到一个错误:

using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.Azure;
using Microsoft.Azure.Storage;
using Microsoft.Azure.Storage.Auth;
using Microsoft.Azure.Storage.Blob;
using Microsoft.Azure.KeyVault;
(1,17): error CS0234: The type or namespace name 'IdentityModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
(3,17): error CS0234: The type or namespace name 'Azure' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
(4,17): error CS0234: The type or namespace name 'Azure' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
(5,17): error CS0234: The type or namespace name 'Azure' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
(6,17): error CS0234: The type or namespace name 'Azure' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
(7,17): error CS0234: The type or namespace name 'Azure' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

我参考了 this 文档并尝试使用以下代码安装软件包:

#r "nuget: Azure.Storage.Blobs, 12.10.0"

我收到以下错误:

Installing package Microsoft.Azure.Storage.Blobs, version 12.10.0...Installing package Microsoft.Azure.Storage.Blobs, version 12.10.0....../tmp/nuget/8572--6c519d5e-0a47-4b01-8cdb-d3d9d5a2562c/Project.fsproj : error NU1101: Unable to find package Microsoft.Azure.Storage.Blobs. No packages exist with this id in source(s): https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json, nuget.org

是否可以在 Synapse Notebooks 中使用这些包?

我们已经在本地环境中进行了测试,方法是在 azure synapse 分析工作区中创建一个 C# 笔记本,然后创建 apache 火花池。

我们已经成功安装了以下软件包

#r "nuget: Azure.Storage.Blobs, 12.10.0" 
#r "nuget:Microsoft.IdentityModel.Clients.ActiveDirectory,5.2.9"
#r "nuget:Azure.Storage.Common,12.9.0"
#r "nuget:Azure.Security.KeyVault.Secrets,4.3.0-beta.2"

这是参考输出屏幕截图。

Post安装你可以使用关键字using安装的包,如下所示:

我们没有找到任何要安装的以下 nugget 包

using Microsoft.Azure.Storage.Auth;
using Microsoft.Azure;

对于存储,您还可以安装 Azure.Storage.Common nugget package,其中包括 Azure Blob(对象)、Azure Data Lake Storage Gen2、Azure 文件和 Azure 队列库。

using Microsoft.Azure.KeyVault; 这个 nugget 包已被弃用,有更新的包可用 Azure.Security.KeyVault.Secrets 根据您使用的 Key Vault 的功能(密钥、机密或证书),请使用以下库之一:

  • Azure.Security.KeyVault.Secrets

  • Azure.Security.KeyVault.Keys

  • Azure.Security.KeyVault.Certificates

这是 Azure 突触分析 SDK 库的git中心link