使用 Azure-Cli 从 Jenkins 将 azure 函数部署到 azure
Using Azure-Cli to deploy an azure function to azure from Jenkins
我已经创建了一个 docker 容器并生成了我的 azure 函数应用程序代码的最终工件。 Azure Cli 已安装在容器中。是否可以使用 Azure Cli 部署到 Azure 并传递凭据?
我尝试了以下命令(凭证示例):
az functionapp deployment user set --user-name "MY_USER" --password "MY_PASS" --subscription "MY_SUBSCRIPTION"
但是会导致以下错误:
Subscription 'MY_SUBSCRIPTION' not recognized. ValidationError: Please run 'az login' to setup account.
如果我登录(这需要在浏览器中输入密码),那么上面的命令似乎有效。
这将成为 CI/CD 的一部分,手动登录不是解决方案。有什么想法吗?
是的,您需要进行身份验证。这里有几个身份验证选项:Sign in with Azure CLI
Authenticating with a service principal is the best way to write secure scripts or programs
您需要使用 service principle to authenticate. But since you mentioned you are using Jenkins, fortunately there are rich set of plugins available for different Azure resources which can handle the authentication for you if you setup in your Jenkins dashboard. For example, in this case you are using az cli
for which you can install https://plugins.jenkins.io/azure-cli/
我已经创建了一个 docker 容器并生成了我的 azure 函数应用程序代码的最终工件。 Azure Cli 已安装在容器中。是否可以使用 Azure Cli 部署到 Azure 并传递凭据?
我尝试了以下命令(凭证示例):
az functionapp deployment user set --user-name "MY_USER" --password "MY_PASS" --subscription "MY_SUBSCRIPTION"
但是会导致以下错误:
Subscription 'MY_SUBSCRIPTION' not recognized. ValidationError: Please run 'az login' to setup account.
如果我登录(这需要在浏览器中输入密码),那么上面的命令似乎有效。
这将成为 CI/CD 的一部分,手动登录不是解决方案。有什么想法吗?
是的,您需要进行身份验证。这里有几个身份验证选项:Sign in with Azure CLI
Authenticating with a service principal is the best way to write secure scripts or programs
您需要使用 service principle to authenticate. But since you mentioned you are using Jenkins, fortunately there are rich set of plugins available for different Azure resources which can handle the authentication for you if you setup in your Jenkins dashboard. For example, in this case you are using az cli
for which you can install https://plugins.jenkins.io/azure-cli/