gpt4 book ai didi

Azure函数应用程序创建

转载 作者:行者123 更新时间:2023-12-03 02:59:38 25 4
gpt4 key购买 nike

我正在使用az functionapp create在Azure中创建函数应用程序,其中创建函数应用程序的apparts还将其挂接到bitbucket存储库。我正在使用参数 --deployment-source-url -u 但它似乎无法以这种方式工作并且给我一个错误。这是通过 jenkin 文件管道完成的

node {
stage('Azure Login') {
withCredentials([azureServicePrincipal('6-8afd-ae40e9cf1e74')]) {
sh 'az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET -t $AZURE_TENANT_ID'
sh 'az account set -s $AZURE_SUBSCRIPTION_ID'
}
}
stage('Build Azure FuntionApp') {

sh 'az functionapp create -g $RG_NAME -p $SP_NAME -n grey-$JOB_NAME-$BUILD_NUMBER -s $SA_NAME --deployment-source-url https:// bitbucket.org/xxxx/functions/s***strong text***rc/develop --debug'
}

如果我输入 --deployment-source-url -u https://[email protected]我得到:

<小时/>

ERROR: az functionapp create: error: argument --deployment-source-url/-u: expected one argument

<小时/>

我尝试不使用 -u 只是: --deployment-source-url https://@bitbucket.org

工作已经完成,但与 bitbucket 存储库的链接尚未建立。得到这个:

enter image description here

那么这项工作是如何进行的呢?为什么如果我输入用户,它会说无效参数,如果我不输入,它会消失,但它可以找到用户。有人用过这个命令来创建函数应用程序吗?谢谢!

最佳答案

如果您想通过azure-cli创建azure函数,您可以在--deployment-source-url之后更改部署资源url >。你可以引用我的命令来创建带有blob触发器的函数,替换你的url。在我这边效果很好。

注意:访问级别应该是公开的,您可以在设置中查看,如下图所示。

enter image description here

az functionapp create --deployment-source-url https://bitbucket.org/xxx/azure-function --resource-group resourcegroupname --consumption-plan-location westeurope --name joyfun22 --storage-account <storage_name>

enter image description here

此外,您还可以使用github存储库来创建函数。

例如,使用以下命令创建带有 blob 触发器的函数

az functionapp create --deployment-source-url https://github.com/Joyw1/Azure-Function-Trigger  --resource-group myResourceGroup --consumption-plan-location westeurope --name <app_name> --storage-account  <storage_name>

更新:

如果您的访问级别是私有(private)。您需要访问 token 才能访问您的 bitbucket 存储库。请按照以下步骤操作。

1.进入Bitbucket Labs -> 访问管理 -> OAuth -> 添加消费者

更多详情,引用这个link .

2.使用 Azure CLI 启用经过身份验证的 git 部署

#!/bin/bash

gitrepo=<Replace with your GitHub repo URL e.g. https://github.com/Azure-Samples/functions-quickstart.git>
token=<Replace with a GitHub access token>

# Enable authenticated git deployment
az functionapp deployment source update-token \
--git-token $token

完整命令请引用此link .

关于Azure函数应用程序创建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50358396/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com