如何从 Azure 云 shell 运行 yaml 文件

问题描述

我使用 Azure CLI 在 Azure Kubernetes Service (AKS) cluster 上创建了一个 Windows Server 容器。在尝试将我的 aspnet core 应用程序部署到 AKS 集群时,我被困在上述链接this step 上。我的 sample.yaml 硬盘驱动器上有 Windows-10 文件,需要使用以下命令在 Azure cloud shell 中运行:

kubectl apply -f sample.yaml

问题:我可以将上面的 sample.yaml 文件放在哪里,以便我可以在 Azure Cloud Shell 中运行上面的命令?我假设它可能必须在我的 Azure 存储帐户中的某个位置,但它应该放在什么地方,以便上面的命令可以识别它的路径?目前它给出了一个预期的错误the path "sample.yaml" does not exist

解决方法

您可以在 Azure 外壳中使用 sample.yamlvinano 直接创建名为 code sample.yaml 的文件,然后复制您的 YAML 定义。

例如,在 Azure Bash 中键入 code sample.yaml。它会打开一个 sample.yaml 文件,然后复制 YMAL 内容并保存。该文件自动存储在您当前的工作路径 /home/user 中。

enter image description here

或者,您可以将您的 sample.yaml 从本地上传到 Azure 路径。

或者,您也可以将文件持久存储到 Azure 文件共享中。要查找 Azure 文件共享,您可以键入 df 命令。

enter image description here