Using axios to make Azure Zip Deploy

Viewed 90

Been struggling with this one, so I need to make a post request to Azure Zip Deploy to get my app there, went from errors such as credentials wrong (fixed) to now where it states

axios({
  headers: { "Content-Type": "'application/json'" },
  method: "post",
  url: 'https://test.scm.azurewebsites.net/api/zipdeploy',
  auth: {
    username: '',
    password: ''
  },
  body: {
    file: filePath
  }
});

Errors I get
Message: 'An error has occurred.', ExceptionMessage: 'An attempt was made to move the file pointer before the beginning of the file.\r\n'

Central Directory corrupt

1 Answers

Try this:

const axios = require('axios');
const fs = require('fs');

siteName = '<your web app name>'
user = '<depolyment user name>'
pwd = '<password>'
ZipPath = '<depolyment zip path>'

stream = fs.createReadStream(ZipPath)

axios({
    headers: { "Content-Type": "application/x-zip-compressed" },
    method: "post",
    url: 'https://'+siteName+'.scm.azurewebsites.net/api/zipdeploy',
    auth: {
      username: user,
      password: pwd
    },
    data: stream
  })

I use a static HTML website deployment .zip file to test:

enter image description here

Log: enter image description here

Result: enter image description here

Related