Azure Command Line (一)入门
一,引言
今天我们讲解一个新的 Azure 的知识,叫 “Azure Command Line”,简称 Azure CLI,具体概念是什么,我这里也不多说了,总结下来,Azure CLI 其实就是 用来管理Azure 资源的跨平台的工具,比如我们可以通过Azure CLI 来创建我们需要的 资源组,Web App, VNET 等等。
二,正文
下载Azure CLI(目前Azure CLI 版本为 2.10.1)
Windows:https://azurecliprod.blob.core.windows.net/msi/azure-cli-2.10.1.msi
微软官方文档-----安装Azure CLI
https://docs.azure.cn/zh-cn/cli/install-azure-cli?view=azure-cli-latest
下载完成并且安装完成后,我们可以通过 cmd 或者 powershell 来检查刚刚安装的azure cli 是否正确的安装完成,以及能够正常使用
命令提示符:
az --version
我们的azure cli 是之前安装的,所以不是最新版本,大家请忽略
我们如果不知道Azure cli 都有哪些命令 我们可以通过以下命令,查看帮助信息
命令提示符:
az --help
实际操作,通过azure cli 创建 Azure Container Registry 资源
什么是Azure Container Registry?
Azure Container Registry(容器注册表)简称 ACR,是基于开源 Docker 注册表 2.0 的托管专用 Docker 注册表服务。 可以创建和维护 Azure 容器注册表来存储与管理专用的 Docker 容器映像和相关项目。说白了,就是在Azure 上创建一个私有的docker images 的 repo
Azure 容器注册表与现有的容器开发和部署管道配合使用,也可使用 Azure 容器注册表任务在 Azure 中生成容器映像。 可以通过源代码提交和基础映像更新等触发器按需生成或完全自动生成。
(1),登陆
az login
选择或者输入拥有Azure 订阅的账号,登陆验证完成后,我们可以看到浏览器会有这样的提示
同时,我们可以在命令提示框中看到当前登陆后的账号的信息
(2),创建资源组
我们可以看到创建资源组的时候,--location,--name 这两个参数是必填参数
--location:eastasia
--name:Web_Test_ACR_RG
az group create --name Web_Test_ACR_RG --location eastasia
我们回到Azure Portal 中找到资源组,刷新看看
(3),创建 Azure Container Registry 服务
我们可以 az 命令 看到 --name,--resource-group,--sku 这些参数是必填参数
--name:cnbateblogwebACR
--resource-group 选择:Web_Test_ACR_RG
--sku:Basic
az acr create --resource-group Web_Test_ACR_RG --name cnbateblogwebACR --sku Basic
我们在 Azure Portal 中的 “Web_Test_ACR_RG” 中找一下 acr 资源
bingo !!!!,创建成功
(四),扩展
我们可以试试刚刚创建的好的 Azure Container Registry ,将本地的项目通过Dockerfile,进行打包,然后将 Images push 到容器注册表中
docker images
登陆创建好的Azure 上的私有的 docker image 的 Repo
查看刚刚创建好的Repo 的 登陆地址
az acr show -g Web_Test_ACR_RG -n cnbateblogwebACR --output json
将 Azure 默认的容器注册表改为自己创建的
az configure --defaults acr=cnbateblogwebACR
az acr login
登陆成功,我们可以将本地名字叫 “k8s.net.demo” 的docker image 推送到Azure 上自己创建的私有的 repo ,也就是容器注册表
标记本地镜像,将其归入某一仓库
docker tag k8s.net.demo cnbateblogwebacr.azurecr.io/k8s.net.demo:v1
docker push cnbateblogwebacr.azurecr.io/k8s.net.demo:v1
我们登陆 Azure Portal 上找到创建好的容器注册表中查看
撒花,今天的分享就结束了,撒花🎉🎉🎉🎉🎉
三,结尾
今天我们简单介绍了一下Azure CLI ,以及通过Azure CLI 去创建Azure 资源组,Azure Container Registry 资源,顺便也介绍ACR资源可以用来干什么。以及将本地的docker image 镜像推送到我们Azure 远端的私有的 repo 上,关于azure cli 的命令,大家可以下载,多去练习练习。
作者:Allen
版权:转载请在文章明显位置注明作者及出处。如发现错误,欢迎批评指正。
- Azure Command Line enable Docker Containers
- p4(command line) and p4v(ui) client and server 快速入门 fr net
- FireBug Logging, Profiling,CommandLine,Console API,使用详解
- error adding symbols: DSO missing from command line
- 互联网协议入门/this/carriage return/line feed
- Command Line in Mac/Linux
- How to identify video formats from command line on Linux
- Perl 命令行处理command line common usage and skill
- 十三、 Spring Boot 启动加载数据 CommandLineRunner
- make module失败的原因cc1: error: unrecognized command line option “-m64
- The Linux Command Line 1-10章总结
- sqlserver2000 安装报错解决方法:command line option syntax error,type
- Unrecognized command line option
- ParseCommandLine
- iOS——Command-Line 查看当前SDK版本并修改默认SDK版本
- How to easily open files and URLs from the command line
- Stsadm command-line tool (Office SharePoint Server)
- Azure IoT 技术研究系列1-入门篇
- [quote] How to determine what target is given in Makefile from the make command-line?
- IDEA命令行缩短器助你解决此问题:Command line is too long. Shorten command line...