我可以将 Azure.Core 命名空间用于非 Azure 项目吗?

问题描述

我使用 autorest 为某些 API 生成 c# 客户端(用于我自己的项目),它可以毫无顾虑地生成我的客户端。

但几个月前我改变了我的开发机器,需要为 autorest (3.2.3) 安装新版本。

它生成客户端,但现在它引用了这个命名空间:

using Azure;
using Azure.Core;
using Azure.Core.Pipeline;  

我的问题:

现在 autorest 只为 azure 生成客户端?

我可以将这个新的 autorest 客户端用于 Azure 以外的任何其他云服务吗?

解决方法

AutoRest 是一种工具,可提供代码生成框架,用于将 OpenAPI 2.0 和 3.0 规范转换为这些规范描述的服务的客户端库。它是在 OpenAPI Initiative 成立时由 Microsoft 开发的。 AutoRest 已经创建了一些扩展来增强 swagger 功能(很多是由于 OpenAPI2 的缺点而创建的)。
它是一个 Node.js 开源工具,用于生成用于访问 RESTful Web API 的客户端库。它可以为 CSharp、Node.js、Python、Java、Ruby、Go、PHP 和 TypeScript 等多种编程语言生成库。
有关更多信息,请参阅以下 github 链接: https://github.com/Azure/autorest.csharp/blob/feature/v3/docs/client/initializing.md

 Now autorest generates only clients for azure?

不,autorest 不会仅为 azure 生成客户端。如果您导入生成时指定的命名空间(在标志 --namespace 下),您可以使用您的客户端。

例如,假设命名空间是 Azure.Pets,您的客户端是 PetsClient。如果导入命名空间,则可以访问客户端。

using Azure.Pets;  
using Azure.Core;  
using Azure.Core.Pipeline;  
const string endpoint = "http://localhost:3000";  
var client = new PetsClient(endpoint);  

Can I use this new autorest clients for any other cloud service other than Azure?

是的,您可以将客户端用于 azure 以外的任何其他云。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...