swa deploy |
您所在的位置:网站首页 › 汗斑有什么办法能去掉 › swa deploy |
swa deploySynopsisswa deploy [configName|outputLocation] [options]Description This command is used to deploy the current project to Azure Static Web Apps. Here are some common use cases: Deploy a front-end app without an APIDeploy a front-end app with an APIDeploy a Blazor appDeployment tokenThe SWA CLI supports deploying using a deployment token. This is usually useful when deploying from a CI/CD environment. You can get a deployment token either from: The Azure portal: Home → Static Web App → Your Instance → Overview → Manage deployment token If you are using the Azure CLI, you can get the deployment token of your project using the following command: az staticwebapp secrets list --name --query "properties.apiKey"If you are using the Azure Static Web Apps CLI, you can use the following command:swa deploy --print-tokenYou can then use that value with the --deployment-token or you can create an environment variable called SWA_CLI_DEPLOYMENT_TOKEN and set it to the deployment token. IMPORTANTDon't store the deployment token in a public repository. It should be kept secret! Deploy a front-end app without an APIYou can deploy a front-end application (without an API) to Azure Static Web Apps by running the following steps: If your front-end application requires a build step, run swa build or refer to your application build instructions.Option 1: From build folder you would like to deploy, run the deploy command: cd build/swa deployNote: the "build" folder must contain the static content of your app to be deployed! Option 2: You can also deploy a specific folder: If your front-end application requires a build step, run swa build or refer to your application build instructions. Deploy your app: swa deploy ./my-distDeploy a front-end app with an APITo deploy both the front-end app and an API to Azure Static Web Apps, use the following steps: If your front-end application requires a build step, run swa build or refer to your application build instructions. Make sure the API language runtime version in the staticwebapp.config.json file is set correctly, for example: { "platform": { "apiRuntime": "node:16" }}NoteIf your project doesn't have any staticwebapp.config.json file, add one under your outputLocation folder. Deploy your app:swa deploy ./my-dist --api-location ./apiDeploy a Blazor appTo deploy a Blazor app with (optional) an API to Azure Static Web Apps, use the following steps: Build your Blazor app in Release mode:dotnet publish -c Release -o bin/publishFrom the root of your project, run the deploy command:swa deploy ./bin/publish/wwwroot --api-location ./ApiDeploy using the swa-cli.config.jsonNoteThe path for outputLocation must be relative to the appLocation. If you are using a swa-cli.config.json configuration file in your project and have a single configuration entry, for example: { "configurations": { "my-app": { "appLocation": "./", "apiLocation": "api", "outputLocation": "frontend", "start": { "outputLocation": "frontend" }, "deploy": { "outputLocation": "frontend" } } }}Then you can deploy your application by running the following steps: If your front-end application requires a build step, run swa build or refer to your application build instructions. Deploy your app: swa deployIf you have multiple configuration entries, you can provide the entry ID to specify which one to use: swa deploy my-otherappOptionsHere are the options you can use with swa deploy: -a, --app-location : the folder containing the source code of the front-end application (default: ".")-i, --api-location : the folder containing the source code of the API application-O, --output-location : the folder containing the built source of the front-end application. The path is relative to --app-location (default: ".")-w, --swa-config-location : the directory where the staticwebapp.config.json file is located-d, --deployment-token : the secret token used to authenticate with the Static Web Apps-dr, --dry-run: simulate a deploy process without actually running it (default: false)-pt, --print-token: print the deployment token (default: false)--env [environment]: the type of deployment environment where to deploy the project (default: "preview")-S, --subscription-id : Azure subscription ID used by this project (default: process.env.AZURE_SUBSCRIPTION_ID)-R, --resource-group : Azure resource group used by this project-T, --tenant-id : Azure tenant ID (default: process.env.AZURE_TENANT_ID)-C, --client-id : Azure client ID-CS, --client-secret : Azure client secret-n, --app-name : Azure Static Web App application name-CC, --clear-credentials: clear persisted credentials before login (default: false)-u, --use-keychain: enable using the operating system native keychain for persistent credentials (default: true)-nu, --no-use-keychain: disable using the operating system native keychain-h, --help: display help for commandUsageDeploy using a deployment token swa deploy ./dist/ --api-location ./api/ --deployment-tokenDeploy using a deployment token from the environment variables SWA_CLI_DEPLOYMENT_TOKEN=123 swa deploy ./dist/ --api-location ./api/Deploy using swa-cli.config.json file swa deployswa deploy myconfigPrint the deployment token swa deploy --print-tokenDeploy to a specific environment swa deploy --env productionSee Alsoswaswa loginEnvironment Variables |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |