0
votes

I am facing this odd situation. I have the following setup.

  • React JS app created using create-react-app
  • Code on GitHub
  • Azure Web App - Create from the Azure Portal.
  • Azure DevOps + Pipelines + YAML

I have been doing a bunch of deployments this week and I noticed this situation. Every 1st deployment, always ends up with the following situation inside the wwwroot folder.

enter image description here

But, every subsequent deployment, works just fine.

To reproduce

  • Create a new app with create-react-app
  • Put it on GitHub
  • Link GitHub repository with Azure DevOps Pipelines
  • Target the Pipeline to deploy to a Azure Web App, which has been created brand new.

The initial deployment, will always fail, with the above image. And, please, remember, Subsequent deployments dont fail.

So, the question is, is there something I can do to prevent this?

I am planning to automate resource creation on Azure, along with automating deployment.

Update 1

as per the comment, including my YAML here. I use this in all of my react JS deployments, which show the same issue as above.

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'


- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- script: |
    npm install
    npm run build
  displayName: 'npm install and build'



- 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: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/build/'
    includeRootFolder: false


- task: AzureWebApp@1
  inputs:
    azureSubscription: 'ReactJSRecipeAppConnection'
    appName: 'ReactJSRecipeAppSep232020'
    package: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip' 
2
maybe it times out? like installing some dependencies and that finishes, but the install timeout and then the second install doesnt need to do that, and hence, doesnt time out - 4c74356b41
I really dont think so. I must have deployed like half a dozen sites this week. constant and continues situation everytime. I cannot believe that every site i ever create is timing out every time. the files are simply not going into the wwwroot folder. somewhere along the way in the pipeline, i think, a config file is not getting properly created. it could be the way azure-devops works. - Jay
why would it work the second time, though? - 4c74356b41
thats what I am hoping to find out :) right now, I am just triggering a second deployment, every time, to overcome this problem. the code, YAML pipeline, nothing is changed. - Jay
@Jay Please share you YAML pipeline and set variable system.debug to true to get detailed log. - Cece Dong - MSFT

2 Answers

1
votes

FAILED TO INITIALIZE RUN FROM PACKAGE usually means the zip file is corrupted or not deflateable. Please check whether the WEBSITE_RUN_FROM_PACKAGE flag under App Service -> Application settings was set.

In addition, try to use task Azure App Service deploy v4, instead of task Azure Web App v1.

0
votes

Taking off from the discussion about with @Cece Dong, here is what eventually worked for me.

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '10.x'
  displayName: 'Install Node.js'

- script: |
    npm install
    npm run build
  displayName: 'npm install and build'

- 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: ArchiveFiles@2
  inputs:
    rootFolderOrFile: '$(Build.ArtifactStagingDirectory)/build/'
    includeRootFolder: false

- task: AzureRMWebAppDeployment@4
  inputs:
    appType: webApp    
    azureSubscription: 'RandomStuffReactJSConnection'
    WebAppName: 'randomstuffreactjsappsept24'
    package: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip' 

The above, I can confirm, no longer requires a second trigger for a proper deployment.

specifically, the usage of 'AzureRMWebAppDeployment@4' is what solved the original issue.