fooiey
fooiey

Reputation: 1570

What path should I point the AzureWebApp task to?

I'm trying to deploy a react web app. Here is my current yaml file. I've been following this tutorial.

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'
  
variables:
  azureSubscription: <myServiceConnection>
  appName: <myAppName>

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'
  
  #so this calls the build object in package.json. Theoretically creates a /build/ directory
- script: |
    npm install
    npm run build
  displayName: 'npm install and build'

#this should copy contents of build into artifactstagingdirectory. 
- task: CopyFiles@2
  inputs:
    Contents: 'build/**' # Pull the build directory (React)
    TargetFolder: '$(Build.ArtifactStagingDirectory)' 

- task: PublishBuildArtifacts@1
  inputs: 
    pathtoPublish: $(Build.ArtifactStagingDirectory) # dist or build files
    ArtifactName: 'www' # output artifact named www


- task: AzureWebApp@1
  inputs:
    azureSubscription: <myServiceConnection>
    appName: <myAppName>
    appType: webAppLinux
    package: $(Build.ArtifactStagingDirectory)/**/www/build
    customWebConfig: '-handler iisnode -NodeStartFile server.js -appType node'

Basically, the issue is that I dont understand where the PublishBuildArtifact task publishes the files, and so I don't know where to point the package of AzureWebApp to.

So I turned on system.debug and I got the following information

  1. npm install build uses the following directory: /home/vsts/work/1/s
  2. copy files copies the build folder over. So it goes /home/vsts/work/1/s/build to /home/vsts/work/1/a/build. So this means artifactstagingdirectory is /home/vsts/work/1/a
  3. Publish Build artifacts takes the artifactstagingdirectory and publishes it to some folder www/build. The following output is provided: Upload '/home/vsts/work/1/a' to file container: '#/8995596/www'
  4. The current AzureWebApp task is looking in /home/vsts/work/1/a/**/www/build

So I think it should be the right directory. However, it is not providing the whole path in step 3. So it looks like I'm wrong. Where is this www folder being created?

Also since it doesn't seem like building/publishing the react app will create a zip file, do I just point it to the build folder or the www folder?

Upvotes: 0

Views: 587

Answers (1)

A Modgil
A Modgil

Reputation: 290

try **/wwwroot/ instead of **/www/

Check following blog from Microsoft with deployment details outlined.

https://learn.microsoft.com/en-us/azure/app-service/faq-deployment

Upvotes: 2

Related Questions