AzureBlob static file copy

rok.lenardic's Avatar

rok.lenardic

20 Apr, 2020 01:22 PM

Hi,

I have an appveyor.yaml config file that goes something like:
 install:
  # Get the latest stable version of Node.js or io.js
  - ps: Install-Product node $env:nodejs_version
  # install modules
  - cmd: cd src\subscribers-app && npm install

 #---------------------------------#
 # build configuration #
 #---------------------------------#
 matrix:
  fast_finish: true

 build_script:
   - npm run build --prefix .\src\subscribers-app
 
 deploy:
  - provider: AzureBlob
    storage_account_name: someazureaccountname
    storage_access_key:
      secure: areallysecurekey
    container: $web
    artifact: build
    set_content_type: false
    unzip: false
    on:
      branch: feature/somejirabranchname

I struggle to understand the "folder vs artifact" concept in order for the npm build results that are located in subscriber-app/build folder to be copied to $web container on azure. How and where do I reference the subscriber-app/build folder so it gets copied with all the files and subfolders to $web container on azure?
Additionally, should be ZIPPING anything explicitly and how do I do that in that case?

Thanks!

  1. Support Staff 1 Posted by Feodor Fitsner on 21 Apr, 2020 04:19 AM

    Feodor Fitsner's Avatar

    Hi Rok,

    Deployment provider works with artifacts, so to make it work artifacts must be uploaded to build results first: https://www.appveyor.com/docs/packaging-artifacts/

    If you want to push the entire contents of subscriber-app\build dir as a single zip it could be something like (that path must be relative to build root folder):

    artifacts:
    - path: subscriber-app\build
      name: MyAppPackage
    

    Notice here, that I'm giving that artifact a "deployment name" (aka label) MyAppPackage to reference it later in deployment provider settings instead of path. Artifacts should appear on "Artifacts" tab of build results.

    Then in deployment settings change artifact: build to artifact: MyAppPackage and set unzip: true to expand zip artifact inside $web container:

     deploy:
      - provider: AzureBlob
        storage_account_name: someazureaccountname
        storage_access_key:
          secure: areallysecurekey
        container: $web
        artifact: MyAppPackage
        set_content_type: true
        unzip: true
        on:
          branch: feature/somejirabranchname
    

    Let me know how that worked.

  2. 2 Posted by rok.lenardic on 21 Apr, 2020 06:22 AM

    rok.lenardic's Avatar

    Feodor,

    that did the trick but needed two tweak:
    1. as webpack config is set for the build folder to be on the root level, only .\build was enough for artifacts > path
    2. set_content_type had to be set to true otherwise when navigating to the page the browser downloads the index.html instead of showing it.

    Below is the final version if anyone needs it at any point.

    Thank you
    Rok

     build_script:
      # Build and publish Host
       - npm run build --prefix .\src\subscribers-app
       
     artifacts:
      - path: .\build
        name: packaged-app

     #---------------------------------#
     # deployment configuration #
     #---------------------------------#

     deploy:
      - provider: AzureBlob
        storage_account_name: someazureaccountname
        storage_access_key:
          secure: areallysecurekey
        container: $web
        artifact: packaged-app
        set_content_type: true
        unzip: true
        on:
          branch: feature/somejirabranchname

  3. Support Staff 3 Posted by Feodor Fitsner on 21 Apr, 2020 06:26 AM

    Feodor Fitsner's Avatar

    Cool, thanks for the update!

  4. 4 Posted by rok.lenardic on 21 Apr, 2020 06:44 AM

    rok.lenardic's Avatar

    Btw, any chance appveyor can do gzip compression for files and set AzureBlob file properties such as CacheControl = "max-age=864000, public, must-revalidate" and ContentEncoding = "gzip"?

  5. rok.lenardic closed this discussion on 22 Jun, 2020 05:58 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac