在Azure中使用API或SDK上传模板
来源:stackoverflow
时间:2024-03-02 20:21:23 206浏览 收藏
积累知识,胜过积蓄金银!毕竟在Golang开发的过程中,会遇到各种各样的问题,往往都是一些细节知识点还没有掌握好而导致的,因此基础知识点的积累是很重要的。下面本文《在Azure中使用API或SDK上传模板》,就带大家讲解一下知识点,若是你对本文感兴趣,或者是想搞懂其中某个知识点,就请你继续往下看吧~
我希望使用 Go SDK 或 Rest API 以编程方式在 Azure 中上传 VM 部署模板。我无法找到相同的正确文档。
此外,我不想启动虚拟机部署。仅限将部署模板上传到Azure。
解决方案
下面是将空模板放入门户的示例 api 请求:
{ "name": "test", "type": "microsoft.gallery/myareas/galleryitems", "properties": { "publishername": "username_goes_here", "publisherdisplayname": "username_goes_here", "displayname": "test", "description": "test", "artifacts": { "default": { "name": "template", "type": "template", "uri": "https://gallery.azure.com/artifact/20161101/microsoft.mygallery.0.0.9-preview/deploymenttemplates/emptytemplate.json" } }, "images": [ { "context": "ibiza", "items": [ { "name": "large", "type": "icon", "uri": "https://gallery.azure.com/galleryrp/content/galleryitemdefaultlargeicon.png" } ] } ], "version": "1.0.0", "uidefinitionuri": "", "publishingstate": "stable", "categoryids": [], "links": [] } }
不确定从哪里获取 guid,可能必须手动创建第一个 guid,或者对 myareas 的获取请求可能会显示可能区域的列表
不幸的是,我没有在任何地方的 api 中看到此记录。
编辑:我能够找到提供者的操作列表:
{ "namespace": "Microsoft.Gallery", "resourceTypes": [ { "resourceType": "myareas", "locations": "", "apiVersions": "2016-03-01-preview", "capabilities": "None" }, { "resourceType": "myareas/areas", "locations": "", "apiVersions": "2016-03-01-preview", "capabilities": "None" }, { "resourceType": "myareas/areas/areas", "locations": "", "apiVersions": "2016-03-01-preview", "capabilities": "None" }, { "resourceType": "myareas/galleryitems", "locations": "", "apiVersions": "2016-03-01-preview", "capabilities": "None" }, { "resourceType": "myareas/areas/galleryitems", "locations": "", "apiVersions": "2016-03-01-preview", "capabilities": "None" }, { "resourceType": "myareas/areas/areas/galleryitems", "locations": "", "apiVersions": "2016-03-01-preview", "capabilities": "None" }, { "resourceType": "enroll", "locations": "", "apiVersions": "2016-03-01-preview", "capabilities": "None" }, { "resourceType": "register", "locations": "", "apiVersions": "2016-03-01-preview", "capabilities": "None" }, { "resourceType": "galleryitems", "locations": "", "apiVersions": "2016-03-01-preview 2014-04-01-preview", "capabilities": "None" }, { "resourceType": "resources", "locations": "", "apiVersions": "2016-03-01-preview 2014-04-01-preview", "capabilities": "None" }, { "resourceType": "retrieveresourcesbyid", "locations": "", "apiVersions": "2016-03-01-preview 2014-04-01-preview", "capabilities": "None" }, { "resourceType": "generateartifactaccessuri", "locations": "", "apiVersions": "2016-03-01-preview", "capabilities": "None" }, { "resourceType": "checknameavailability", "locations": "", "apiVersions": "2016-03-01-preview", "capabilities": "None" } ] }
所以我不认为它是 ui 代理。它似乎是一个真正的提供商,但它似乎位于租户级别或其他什么?请注意 url:https://management.azure.com/providers
。
编辑:是的,我可以通过此调用获取我的区域列表:https://management.azure.com/providers/microsoft.gallery/myareas/?api-version=2020-01-01
它将返回我迄今为止唯一的区域:df010a79-26a3-401a-8697-a5736c82895a
今天带大家了解了的相关知识,希望对你有所帮助;关于Golang的技术知识我们会一点点深入介绍,欢迎大家关注golang学习网公众号,一起学习编程~
-
502 收藏
-
502 收藏
-
501 收藏
-
501 收藏
-
501 收藏
-
139 收藏
-
204 收藏
-
325 收藏
-
477 收藏
-
486 收藏
-
439 收藏
-
357 收藏
-
352 收藏
-
101 收藏
-
440 收藏
-
212 收藏
-
143 收藏
-
- 前端进阶之JavaScript设计模式
- 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。
- 立即学习 542次学习
-
- GO语言核心编程课程
- 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。
- 立即学习 508次学习
-
- 简单聊聊mysql8与网络通信
- 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让
- 立即学习 497次学习
-
- JavaScript正则表达式基础与实战
- 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。
- 立即学习 487次学习
-
- 从零制作响应式网站—Grid布局
- 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。
- 立即学习 484次学习