简体   繁体   English

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

[英]How to install packages in Azure Synapse C# notebooks?

I need to use a few packages to run notebooks in Synapse in C#.我需要使用几个包在 C# 中的 Synapse 中运行笔记本。 Running the following snippet, I get an error:运行以下代码段,出现错误:

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?)

I referred to this documentation and tried to use the following code to install the package:我参考了这个文档并尝试使用以下代码来安装包:

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

I get the following error:我收到以下错误:

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

Is it possible to use these packages in Synapse Notebooks?是否可以在 Synapse Notebooks 中使用这些软件包?

I don't think I have a full answer for you especially as it's not obvious what you are trying to achieve, however this article might help from some of your needs working with Blob data in Notebooks: https://docs.microsoft.com/en-us/azure/synapse-analytics/spark/microsoft-spark-utilities?pivots=programming-language-csharp我不认为我有一个完整的答案给你,特别是因为你想要实现的目标并不明显,但是这篇文章可能会帮助你处理笔记本中 Blob 数据的一些需求: https : //docs.microsoft.com /en-us/azure/synapse-analytics/spark/microsoft-spark-utilities?pivots=programming-language-csharp

On review this looks like exactly what you need as there are sections on authentication and key vault access.在审查中,这看起来正是您需要的,因为有关于身份验证和密钥库访问的部分。

We have tested in our local environment, by creating a C# notebook in azure synapse analytics workspace followed by creating apache spark pools.我们已经在本地环境中进行了测试,方法是在 azure synapse 分析工作区中创建一个 C# 笔记本,然后创建 apache 火花池。

we have successfully installed the below packages我们已经成功安装了以下软件包

#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"

Here is the reference output screen shot.这是参考输出屏幕截图。

在此处输入图片说明

Post the installation you can use those installed package by using the keyword using as shown in below :发布安装后,您可以使用关键字using使用那些已安装的包,如下所示:

在此处输入图片说明

We didn't found any of the below nugget packages to install using Microsoft.Azure.Storage.Auth;我们没有找到以下任何要使用 Microsoft.Azure.Storage.Auth 安装的块包; using Microsoft.Azure;使用 Microsoft.Azure;

for storage you can also install Azure.Storage.Common nugget package which includes Azure Blobs (objects), Azure Data Lake Storage Gen2, Azure Files, and Azure Queues libraries .对于存储,您还可以安装Azure.Storage.Common块包,其中包括 Azure Blob(对象)、Azure Data Lake Storage Gen2、Azure 文件和 Azure 队列库。

using Microsoft.Azure.KeyVault; this nugget package got deprecated a newer package is available Azure.Security.KeyVault.Secrets Depending on what functionality of Key Vault you are using (Keys, Secrets or Certificates), please use one of the following libraries:这个 nugget 包被弃用了一个较新的包可用Azure.Security.KeyVault.Secrets根据您使用的 Key Vault 的功能(密钥、机密或证书),请使用以下库之一:

  • Azure.Security.KeyVault.Secrets Azure.Security.KeyVault.Secrets

  • Azure.Security.KeyVault.Keys Azure.Security.KeyVault.Keys

  • Azure.Security.KeyVault.Certificates Azure.Security.KeyVault.Certificates

Here is the git hub link for Azure synapse Analytics SDK libraries这是 Azure 突触分析 SDK 库的 git hub 链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM