You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行dotnet lambda deploy-function时遇Region、StartUrl属性不能为空错误求助

问题分析与解决

核心问题

你遇到的错误Value cannot be null. (Parameter 'Property cannot be empty: Region, StartUrl')源于两个关键配置错误:

  1. 用传统的aws configure创建的my-profile并未关联SSO会话信息,导致部署工具无法获取SSO所需的Region和StartUrl参数。
  2. aws-lambda-tools-defaults.json中的profile字段配置错误,填写的是SSO权限集名称而非你的CLI配置文件名称。

另外,关于两个SSO登录命令的区别,下文会详细说明。

分步解决

1. 重新配置关联SSO的AWS CLI Profile

传统的aws configure用于配置Access Key/Secret Key类型的身份验证,而SSO需要用专门的命令配置:

  • 先清理旧配置(可选):打开Windows下的C:\Users\<你的用户名>\.aws\config和credentials文件,删除包含[profile my-profile]的段落。
  • 执行命令:
    aws configure sso
    
    按照提示依次输入:
    • SSO启动URL(AWS SSO控制台提供的URL,比如https://d-xxxxxx.awsapps.com/start)
    • SSO所在区域(比如us-east-1)
    • 登录后选择对应的AWS账户和权限集(比如AdministratorAccess)
    • 最后指定profile名称为my-profile
  • 验证配置:打开config文件,[profile my-profile]下应包含sso_session = my-sso、sso_account_id、sso_role_name、region等SSO相关配置项。

2. 修正Lambda工具配置文件

修改aws-lambda-tools-defaults.json中的profile字段,将"AdministratorAccess"改为你配置的CLI profile名称"my-profile",修正后的配置片段:

{
  // ... 其他配置不变
  "profile": "my-profile",
  "region": "us-east-1",
  // ... 其他配置不变
}

3. 重新执行登录与部署

  • 执行SSO登录:
    aws sso login --profile "my-profile"
    
  • 重新部署Lambda:
    dotnet lambda deploy-function SimpleLambdaApi --profile "my-profile"
    

两个SSO登录命令的区别

  • aws sso login --profile "my-profile":读取指定profile的配置,自动使用其关联的SSO会话完成登录,适合日常固定使用某个profile的场景。
  • aws sso login --sso-session "my-sso":直接指定已创建的SSO会话(通过aws configure sso-session创建),无需依赖某个profile的关联,适合同一个SSO会话需要给多个profile共用的场景。

内容的提问来源于stack exchange,提问作者Thomas Parikka

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.09 15:00:29