AzureStaticWebApp@0 - 部署 Azure 静态 Web 应用 v0 任务
此任务生成并部署 Azure 静态 Web 应用。
语法
# Deploy Azure Static Web App v0
# Build and deploy an Azure Static Web App.
- task: AzureStaticWebApp@0
inputs:
#workingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd | rootDirectory. Working directory. Default: $(System.DefaultWorkingDirectory).
#app_location: # string. App location.
#app_build_command: # string. App build command.
#output_location: # string. Output location.
#api_location: # string. Api location.
#api_build_command: # string. Api build command.
#routes_location: # string. Routes location.
#config_file_location: # string. Config file location.
#skip_app_build: # boolean. Skip app build.
#skip_api_build: # boolean. Skip api build.
#is_static_export: # boolean. Set static export.
#verbose: # boolean. Verbose.
#build_timeout_in_minutes: # string. Build timeout in minutes.
#azure_static_web_apps_api_token: # string. Azure Static Web Apps api token.
#deployment_environment: # string. Deployment Environment.
#production_branch: # string. Production Branch.
#data_api_location: # string. Data api location.
# Deploy Azure Static Web App v0
# Build and deploy an Azure Static Web App.
- task: AzureStaticWebApp@0
inputs:
#workingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd | rootDirectory. Working directory. Default: $(System.DefaultWorkingDirectory).
#app_location: # string. App location.
#app_build_command: # string. App build command.
#output_location: # string. Output location.
#api_location: # string. Api location.
#api_build_command: # string. Api build command.
#routes_location: # string. Routes location.
#config_file_location: # string. Config file location.
#skip_app_build: # boolean. Skip app build.
#skip_api_build: # boolean. Skip api build.
#is_static_export: # boolean. Set static export.
#verbose: # boolean. Verbose.
#build_timeout_in_minutes: # string. Build timeout in minutes.
#azure_static_web_apps_api_token: # string. Azure Static Web Apps api token.
#deployment_environment: # string. Deployment Environment.
#production_branch: # string. Production Branch.
输入
workingDirectory
-
工作目录
输入别名:cwd | rootDirectory
。
string
。 默认值:$(System.DefaultWorkingDirectory)
。
指定要在其中执行此任务的绝对工作目录。 如果留空,则使用默认工作目录。
app_location
-
应用位置
string
。
应用程序源代码的目录位置,相对于工作目录。 与 skip_app_build: true
一起使用时,此值是应用的生成输出位置。
app_build_command
-
应用生成命令
string
。
生成应用程序源代码时用于运行 Oryx 的自定义命令。
output_location
-
输出位置
string
。
生成完成后编译的应用程序代码的目录位置相对于工作目录。 绕过自动生成时,将此字符串设置为空字符串(''
),并且只需要部署。
api_location
-
Api 位置
string
。
Azure Functions 源代码相对于工作目录的目录位置。
api_build_command
-
Api 生成命令
string
。
生成 Azure Functions 源代码时用于运行 Oryx 的自定义命令。
routes_location
-
路由位置
string
。
相对于工作目录 routes.json 文件的目录位置。
注意:已弃用 Routes.json。 使用 staticwebapp.config.json。
config_file_location
-
配置文件位置
string
。
相对于工作目录 staticwebapp.config.json 文件的目录位置。
skip_app_build
-
跳过应用生成
boolean
。
跳过应用文件夹的 Oryx 生成。
skip_api_build
-
跳过 api 生成
boolean
。
跳过 API 文件夹的 Oryx 生成。
is_static_export
-
设置静态导出
boolean
。
将应用程序配置为导出到静态 HTML 时,请将此标志设置为 true
,就像使用 next export
时一样。
将此标志设置为 true
verbose
-
详细
boolean
。
启用详细日志记录。
build_timeout_in_minutes
-
生成超时(以分钟为单位)
string
。
指定 Oryx 应用文件夹生成的时间限制(以分钟为单位)。
azure_static_web_apps_api_token
-
Azure 静态 Web 应用 API 令牌
string
。
指定用于部署的 API 令牌。
注意:如果作为环境变量传递,则不需要。
deployment_environment
-
部署环境
string
。
指定要部署到的环境。 为生产环境留空。 此输入优先于生产分支。
production_branch
-
生产分支
string
。
指定生产分支。 定义并且部署环境为空时,来自其他分支的部署将是预览环境。
data_api_location
-
数据 API 位置
string
。
数据 API 源文件相对于工作目录的目录位置。
任务控制选项
除任务输入之外,所有任务都具有控制选项。 有关详细信息,请参阅 控件选项和常见任务属性。
输出变量
此任务定义以下 输出变量,可以在下游步骤、作业和阶段中使用。
AZURESTATICWEBAPP_STATIC_WEB_APP_URL
成功部署后, 静态 Web 应用的 URL。
言论
注意
此任务仅在 Linux 代理上运行。
例子
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
submodules: true
- task: AzureStaticWebApp@0
inputs:
app_location: '/build'
api_location: 'api'
output_location: '/output'
azure_static_web_apps_api_token: $(deployment_token)
跳过生成前端应用并仅运行部署
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '20.x'
displayName: 'Install Node.js'
- script: |
npm ci
npm run build
displayName: 'dependencies install and distribution build'
- task: AzureStaticWebApp@0
inputs:
app_location : '/dist'
output_location: '' # Leave this empty
skip_app_build: true
skip_api_build: true
azure_static_web_apps_api_token: $(deployment_token)