【问题标题】:Deploy to serverless Azure Functions Failed部署到无服务器 Azure Functions 失败
【发布时间】:2020-09-09 11:14:10
【问题描述】:

我正在尝试在 Azure 门户中已创建的应用服务中部署 Azure Functions。

使用 sls deploy CLI 部署我的 Azure 函数,但在部署函数时 sls 正在尝试创建我无权访问的新资源组。

以下是sls deploy 命令的输出:

$ sls deploy
Serverless: Removing .serverless directory
Serverless: Parsing Azure Functions Bindings.json...
Serverless: Building binding for function: admin event: httpTrigger
Serverless: Parsing Azure Functions Bindings.json...
Serverless: Building binding for function: image event: httpTrigger
Serverless: Parsing Azure Functions Bindings.json...
Serverless: Building binding for function: report event: httpTrigger
Serverless: Parsing Azure Functions Bindings.json...
Serverless: Building binding for function: gaims event: httpTrigger
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Logging into Azure
Serverless: Using subscription ID: <SUBSCRIPTION_ID>
Serverless: Creating resource group: <ALREADY_CREATED_RESOURCE_GROUP_NAME>

  Error --------------------------------------------------

  Error: The client '<USER_NAME>' with object id '<OBJECT_ID>' does not have authorization to perform action 
     'Microsoft.Resources/subscriptions/resourcegroups/write' over scope 
    '/subscriptions/SUBSCRIPTION_ID/resourcegroups/ALREADY_CREATED_RESOURCE_GROUP_NAME' or the scope is invalid. 
    If access was recently granted, please refresh your credentials.
      at new RestError (C:\Users\analysis-node\node_modules\@azure\ms-rest-js\lib\restError.ts:18:5)
      at C:\Users\analysis-node\node_modules\@azure\ms-rest-js\lib\policies\deserializationPolicy.ts:117:27
      at process._tickCallback (internal/process/next_tick.js:68:7)

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          win32
     Node Version:              10.20.1
     Framework Version:         1.71.1
     Plugin Version:            3.6.12
     SDK Version:               2.3.0
     Components Version:        2.30.11

serverless.yml 中,我还指定了resourceGroup 参数。这是serverless.yml的要点

provider:
  stage: dev
  name: azure
  region: East US 2
  runtime: nodejs10.x
  resourceGroup: <ALREADY_CREATED_RESOURCE_GROUP_NAME>
  subscriptionId: <SUBSCRIPTION_ID>

有什么方法可以在serverless cli 中设置资源组,可以在部署功能时使用?

【问题讨论】:

  • 从错误消息看来,尝试执行此操作的服务主体/用户没有创建资源的权限,不是吗?应该是贡献者吧。这里有一个类似的问题 [stackoverflow.com/a/37689720/5344880] 接受的答案。希望有帮助
  • 不打算创建资源组。只想在应用服务下部署我的功能。
  • @ParagJadhav 我同意Guru,您应该检查您用于部署该功能的服务主体或用户的订阅权限。
  • @TonyJu 我有一个贡献者可以访问我确定的功能。如果我在 VS Code 中使用 Azure 函数扩展生成新的项目模板,我什至可以在当前应用服务中部署该函数。如果您希望我更详细地更新问题,请告诉我

标签: azure azure-functions serverless-framework serverless


【解决方案1】:

我能够通过将部署分为两部分来部署 Azure 功能

  1. 使用serverless打包项目。

    sls package
    
  2. 使用 Azure CLI 部署打包的 zip 文件。

    az functionapp deployment source config-zip -g {RESOURCE_GROUP} -n {APP_SERVICE_NAME} --src .serverless/project-zip.zip
    

希望这对面临同样问题的人有所帮助。

编辑:

看起来这个问题可能会在即将发布的版本中得到解决。

链接:https://github.com/serverless/serverless-azure-functions/issues/469

【讨论】:

    猜你喜欢
    • 2019-12-24
    • 1970-01-01
    • 2018-05-17
    • 2014-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    相关资源
    最近更新 更多