Azure / Azure/static-web-apps-cli
CLI is not correctly deploying dotnet API application.
- Dominant language
- TypeScript
- Stars
- 668
- Forks
- 156
- PR merge metrics
- No merged PRs in 30d
Description
Before filing this issue, please ensure you're using the latest CLI by running `swa --version` and comparing to the latest version on [npm](https://www.npmjs.com/package/@azure/static-web-apps-cli).
**Are you accessing the CLI from the default port `:4280` ?**
- [ ] No, I am using a different port number (`--port`) and accessing the CLI from that port
- [X] Yes, I am accessing the CLI from port `:4280`
> Make sure you are accessing the URL printed in the console when running `swa start`!
**ℹ️ NOTE: Make sure to enable debug logs when running any `swa` commands using `--verbose=silly`**
**Describe the bug**
My application is using parcel to generate static web files backed by a dotnet 6 HTTP function, which works fine using `swa start` locally. When using `swa deploy` the API is not found. It does not appear in the API section of the resource in Azure's portal and calls from the UI result in a 404. The project is using an `api` directory off the root of the project. The zip files are generated and deployed for the static app and the API.
Note that on the portal Overview blade it does show Function errors, but does not indicate any Function hits. The Application Insights blade also shows the warning message, "App Insights is only applicable to Static Web Apps with at least one function. Add a function to your app to enable App Insights."
**To Reproduce**
Steps to reproduce the behavior:
1. Go to the root of the project
2. Type in command 'swa deploy -O ./dist/ -i ./api/'
3. Click on the URL generated by the command
4. Open up the browser console
5. See 404 error
**Expected behavior**
I'm expecting to see the call to the API succeed. In addition, I expect to see the API show up in the API section of the resource on the Azure Portal.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: Windows 11 (Build 22622.598)
- Editor: VS Code
- Azure Function Tools: 4.0.4736
- Dotnet SDK: 6.0.304
- AZ CLI: 2.4.0
- SWA CLI: 1.0.2
- npm: 8.19.2
**Additional context**
```
PS C:\source\z-hack-dreamworld\geotag> swa deploy -O ./dist/ -i ./api/ --verbose=silly
Welcome to Azure Static Web Apps CLI (1.0.2)
Getting config file options from swa-cli.config.json...
Changed directory to C:\source\z-hack-dreamworld\geotag
Using configuration "geotag" from file:
C:\source\z-hack-dreamworld\geotag\swa-cli.config.json
Deploying front-end files from folder:
C:\source\z-hack-dreamworld\geotag\dist
Deploying API from folder:
C:\source\z-hack-dreamworld\geotag\api
No deployment token found. Trying interactive login...
Checking Azure session...
Executing authenticateWithAzureIdentity
- details:
- tenantId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- clientId:
- clientSecret:
- useKeychain: true
Keychain is enabled
Executing swaCliPersistencePlugin
Executing before cache access plugin
Machine ID:
Invoking crypto service
Getting credentials
Getting credentials from native keychain
Getting keychain reference
isKeychainEnabled: true
KeychainCache: undefined
Attempting to load native keychain
Got native keychain reference
Got native keychain reference
Got credentials from native keychain:
Credentials found in native keychain
Credentials is chunked. Reading all chunks...
Got all chunks successfully
Credentials:
Decrypting credentials
Decrypted credentials:
Credentials content:
Credentials:
Before cache access plugin. Done.
Executing after cache access plugin
Machine ID:
Invoking crypto service
Did TokenCacheContext cache changed: false
After cache access plugin. Done.
✔ Successfully logged into Azure!
Selected tenant: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Selected subscription: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Project credentials:
- subscriptionId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- tenantId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- clientId:
- clientSecret:
Login successful
Checking project "MyProject" settings...
Looking for project "MyProject"...
Static site found!
- staticSite:
- id: /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.Web/staticSites/MyProject
- name: MyProject
- location: East US 2
- type: Microsoft.Web/staticSites
- tags:
- Used: Yes
- sku:
- name: Free
- tier: Free
- defaultHostname: fakename.1.azurestaticapps.net
- repositoryUrl:
- branch:
- customDomains:
- privateEndpointConnections:
- stagingEnvironmentPolicy: Enabled
- allowConfigFileUpdates: true
- contentDistributionEndpoint: https://content-eus2.infrastructure.1.azurestaticapps.net
- keyVaultReferenceIdentity: SystemAssigned
- userProvidedFunctionApps:
- provider: None
- enterpriseGradeCdnStatus: Disabled
Project settings:
- resourceGroupName: MyResourceGroup
- staticSiteName: MyProject
- subscriptionId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
✔ Successfully setup project!
Saving project settings to swa-cli.config.json...
Updating configuration file at C:\source\z-hack-dreamworld\geotag\swa-cli.config.json
Loading existing swa-cli.config.json file at C:\source\z-hack-dreamworld\geotag\swa-cli.config.json
Deployment token provided via remote configuration
- deploymentToken:
Deploying to environment: preview
Trying to read workflow config with values:
- appLocation: C:\source\z-hack-dreamworld\geotag
- outputLocation: C:\source\z-hack-dreamworld\geotag\dist
- apiLocation: C:\source\z-hack-dreamworld\geotag\api
No workflow config folder found at C:\source\z-hack-dreamworld\geotag\.github\workflows
Validating user workflow config (BEFORE):
- appLocation: C:\source\z-hack-dreamworld\geotag
- outputLocation: C:\source\z-hack-dreamworld\geotag\dist
- apiLocation: C:\source\z-hack-dreamworld\geotag\api
Validating user workflow config (AFTER):
- appLocation: C:\source\z-hack-dreamworld\geotag
- apiLocation: C:\source\z-hack-dreamworld\geotag\api
- outputLocation: C:\source\z-hack-dreamworld\geotag\dist
Writing configuration "geotag" to swa-cli.config.json
- appLocation: .
- apiLocation: api
- outputLocation: dist
- appName: MyProject
- resourceGroupName: MyResourceGroup
Loading staticwebapp.config.json schema...
Schema loaded successfully from https://json.schemastore.org/staticwebapp.config.json
Compiling schema...
Reading content from staticwebapp.config.json...
Parsing staticwebapp.config.json...
Validating staticwebapp.config.json...
File validated successfully. Continuing with configuration!
Content parsed successfully
Found configuration file:
C:\source\z-hack-dreamworld\geotag\staticwebapp.config.json
Deploying project to Azure Static Web Apps...
Fetching release metadata for version: stable. Please wait...
- version: stable
- buildId: 1.0.020391
- publishDate: 2022-08-01T17:11:02.6122551Z
- files:
- linux-x64:
- url: https://swalocaldeploy.azureedge.net/downloads/1.0.020391/linux/StaticSitesClient
- sha: 2f2accf69fbc9eb87c9ef35900f61771cfa7d449d177babe6534cc0f952ad993
- win-x64:
- url: https://swalocaldeploy.azureedge.net/downloads/1.0.020391/windows/StaticSitesClient.exe
- sha: 100cc717758ea6ef4af52957128fb0e6b0edd67b0d98b504eabbe7b708f0376e
- osx-x64:
- url: https://swalocaldeploy.azureedge.net/downloads/1.0.020391/macOS/StaticSitesClient
- sha: 34e91e8631e042839f50db6a78d87de62f57401d2a3f4ab616b6bb51264b9411
Local client binary is up to date. Skipping download.
Deploying using C:\Users\scott\.swa\deploy\1.0.020391\StaticSitesClient.exe@1.0.020391
Deploying using the following options:
- env:
- SWA_CLI_DEBUG: silly
- SWA_RUNTIME_WORKFLOW_LOCATION:
- SWA_RUNTIME_CONFIG_LOCATION: C:\source\z-hack-dreamworld\geotag
- SWA_RUNTIME_CONFIG: C:\source\z-hack-dreamworld\geotag\staticwebapp.config.json
- SWA_CLI_VERSION: 1.0.2
- SWA_CLI_DEPLOY_DRY_RUN: false
- SWA_CLI_DEPLOY_BINARY: C:\Users\scott\.swa\deploy\1.0.020391\StaticSitesClient.exe@1.0.020391
- DEPLOYMENT_ACTION: upload
- DEPLOYMENT_PROVIDER: swa-cli-1.0.2
- REPOSITORY_BASE: C:\source\z-hack-dreamworld\geotag
- SKIP_APP_BUILD: true
- SKIP_API_BUILD: true
- DEPLOYMENT_TOKEN:
- APP_LOCATION: C:\source\z-hack-dreamworld\geotag\dist
- API_LOCATION: C:\source\z-hack-dreamworld\geotag\api
- CONFIG_FILE_LOCATION: C:\source\z-hack-dreamworld\geotag
- VERBOSE: true
- DEPLOYMENT_ENVIRONMENT: preview
ℹ DeploymentId: c4d368c4-1230-4808-bc3c-26b48f03100b
ℹ
ℹ Verbose logging enabled
ℹ Build timeout not specified, defaulting to 15 minutes
ℹ App Directory Location: 'C:\source\z-hack-dreamworld\geotag\dist' was found.
ℹ config_file_location: config file 'C:\source\z-hack-dreamworld\geotag\staticwebapp.config.json' was found.
ℹ Looking for event info
ℹ Event info parsed from action options.
ℹ Could not get repository branch. Proceeding
ℹ Could not get repository url. Proceeding
ℹ Skipping step to build C:\source\z-hack-dreamworld\geotag\dist with Oryx
ℹ Api Directory Location: 'C:\source\z-hack-dreamworld\geotag\api' was found.
ℹ Didn't find Oryx manifest file under location: C:\source\z-hack-dreamworld\geotag\ss-oryx\app-manifest\oryx-manifest.toml
ℹ Determined default file to be: index.html
ℹ Using 'staticwebapp.config.json' file for configuration information, 'routes.json' will be ignored.
ℹ Skipping step to build C:\source\z-hack-dreamworld\geotag\api with Oryx
ℹ Function Runtime Information. OS: windows, Functions Runtime: ~4, dotnet version: 6.0
ℹ Zipping Api Artifacts
ℹ Api Zip will be created from directory: C:\source\z-hack-dreamworld\geotag\api
ℹ Api Content Hash: 190108b5b766139125fb7fbca3ec5134
ℹ Done Zipping Api Artifacts
ℹ Zipping App Artifacts
ℹ App Zip will be created from directory: C:\source\z-hack-dreamworld\geotag\dist
ℹ Done Zipping App Artifacts
ℹ Uploading build artifacts.
ℹ Finished Upload. Polling on deployment.
ℹ Status: InProgress. Time: 0.054465(s)
ℹ Status: InProgress. Time: 15.7585498(s)
ℹ Status: Succeeded. Time: 31.018438(s)
ℹ Deployment Complete :)
ℹ Thanks for using Azure Static Web Apps!
✔ Project deployed to https://fakename-preview.eastus2.1.azurestaticapps.net 🚀
```
Contributor guide
Assessment
This issue has not been assessed yet.