Save-AzrWebApp func downloads a wrong SourcePath












0















I'm using Save-AzrWebApp function to downloads files from an Azure Web App.



How to do it is described here: https://blog.ipswitch.com/how-to-copy-files-from-an-azure-app-service-with-powershell



My problem is: it doesn't matter which SourcePath I set, it always downloads me files from wwwroot folder.



Code example that I use:



$syncParams = @{
SourcePath = 'wwwroothistory'
TargetPath = $TargetPath
ComputerName = "https://$Name.scm.azurewebsites.net:443/msdeploy.axd?site=$Name"
Credential = $Credential

}
Sync-Website @syncParams
Get-Item -Path $TargetPath


Actually it doesn't matter what I put into SourcePath (even not existing path) it will download content of wwwroot.
How to use it in a proper way?










share|improve this question





























    0















    I'm using Save-AzrWebApp function to downloads files from an Azure Web App.



    How to do it is described here: https://blog.ipswitch.com/how-to-copy-files-from-an-azure-app-service-with-powershell



    My problem is: it doesn't matter which SourcePath I set, it always downloads me files from wwwroot folder.



    Code example that I use:



    $syncParams = @{
    SourcePath = 'wwwroothistory'
    TargetPath = $TargetPath
    ComputerName = "https://$Name.scm.azurewebsites.net:443/msdeploy.axd?site=$Name"
    Credential = $Credential

    }
    Sync-Website @syncParams
    Get-Item -Path $TargetPath


    Actually it doesn't matter what I put into SourcePath (even not existing path) it will download content of wwwroot.
    How to use it in a proper way?










    share|improve this question



























      0












      0








      0








      I'm using Save-AzrWebApp function to downloads files from an Azure Web App.



      How to do it is described here: https://blog.ipswitch.com/how-to-copy-files-from-an-azure-app-service-with-powershell



      My problem is: it doesn't matter which SourcePath I set, it always downloads me files from wwwroot folder.



      Code example that I use:



      $syncParams = @{
      SourcePath = 'wwwroothistory'
      TargetPath = $TargetPath
      ComputerName = "https://$Name.scm.azurewebsites.net:443/msdeploy.axd?site=$Name"
      Credential = $Credential

      }
      Sync-Website @syncParams
      Get-Item -Path $TargetPath


      Actually it doesn't matter what I put into SourcePath (even not existing path) it will download content of wwwroot.
      How to use it in a proper way?










      share|improve this question
















      I'm using Save-AzrWebApp function to downloads files from an Azure Web App.



      How to do it is described here: https://blog.ipswitch.com/how-to-copy-files-from-an-azure-app-service-with-powershell



      My problem is: it doesn't matter which SourcePath I set, it always downloads me files from wwwroot folder.



      Code example that I use:



      $syncParams = @{
      SourcePath = 'wwwroothistory'
      TargetPath = $TargetPath
      ComputerName = "https://$Name.scm.azurewebsites.net:443/msdeploy.axd?site=$Name"
      Credential = $Credential

      }
      Sync-Website @syncParams
      Get-Item -Path $TargetPath


      Actually it doesn't matter what I put into SourcePath (even not existing path) it will download content of wwwroot.
      How to use it in a proper way?







      powershell azure-web-sites azure-powershell






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 27 '18 at 2:37









      Joy Wang

      7,2832213




      7,2832213










      asked Nov 26 '18 at 14:16









      Denis KoreybaDenis Koreyba

      1,62511233




      1,62511233
























          1 Answer
          1






          active

          oldest

          votes


















          1














          If you want to download file from web app, you could use this web app kudu api via powershell.



          Try the command below, it works fine on my side.



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))

          $apiUrl = "https://joywebapp2.scm.azurewebsites.net/api/vfs/site/wwwroot/Content/Site.css"
          Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo);"If-Match"="*"} -Method GET -ContentType "multipart/form-data" -OutFile "C:UsersjoywDesktoptest.css"


          Test result:



          enter image description here



          enter image description here



          Update:



          If you want to download a folder, you can use the Zip api in the doc I mentioned, it allows downloading folder as a zip file.



          Sample command:



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))

          $apiUrl = "https://joywebapp2.scm.azurewebsites.net/api/zip/site/wwwroot/Scripts/"
          Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo);"If-Match"="*"} -Method GET -ContentType "multipart/form-data" -OutFile "C:UsersjoywDesktopScripts.zip"


          Note:The zip doesn't include the top folder itself. Make sure you include
          the trailing slash, e.g, I download the Scripts folder, we need to use Scripts/ in the apiUrl.






          share|improve this answer


























          • I need to download a folder.

            – Denis Koreyba
            Nov 27 '18 at 10:34











          • No, it's not what I asked for.

            – Denis Koreyba
            Nov 29 '18 at 9:36











          • @DenisKoreyba It does not download the folder?

            – Joy Wang
            Nov 29 '18 at 9:39











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53483042%2fsave-azrwebapp-func-downloads-a-wrong-sourcepath%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          If you want to download file from web app, you could use this web app kudu api via powershell.



          Try the command below, it works fine on my side.



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))

          $apiUrl = "https://joywebapp2.scm.azurewebsites.net/api/vfs/site/wwwroot/Content/Site.css"
          Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo);"If-Match"="*"} -Method GET -ContentType "multipart/form-data" -OutFile "C:UsersjoywDesktoptest.css"


          Test result:



          enter image description here



          enter image description here



          Update:



          If you want to download a folder, you can use the Zip api in the doc I mentioned, it allows downloading folder as a zip file.



          Sample command:



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))

          $apiUrl = "https://joywebapp2.scm.azurewebsites.net/api/zip/site/wwwroot/Scripts/"
          Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo);"If-Match"="*"} -Method GET -ContentType "multipart/form-data" -OutFile "C:UsersjoywDesktopScripts.zip"


          Note:The zip doesn't include the top folder itself. Make sure you include
          the trailing slash, e.g, I download the Scripts folder, we need to use Scripts/ in the apiUrl.






          share|improve this answer


























          • I need to download a folder.

            – Denis Koreyba
            Nov 27 '18 at 10:34











          • No, it's not what I asked for.

            – Denis Koreyba
            Nov 29 '18 at 9:36











          • @DenisKoreyba It does not download the folder?

            – Joy Wang
            Nov 29 '18 at 9:39
















          1














          If you want to download file from web app, you could use this web app kudu api via powershell.



          Try the command below, it works fine on my side.



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))

          $apiUrl = "https://joywebapp2.scm.azurewebsites.net/api/vfs/site/wwwroot/Content/Site.css"
          Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo);"If-Match"="*"} -Method GET -ContentType "multipart/form-data" -OutFile "C:UsersjoywDesktoptest.css"


          Test result:



          enter image description here



          enter image description here



          Update:



          If you want to download a folder, you can use the Zip api in the doc I mentioned, it allows downloading folder as a zip file.



          Sample command:



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))

          $apiUrl = "https://joywebapp2.scm.azurewebsites.net/api/zip/site/wwwroot/Scripts/"
          Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo);"If-Match"="*"} -Method GET -ContentType "multipart/form-data" -OutFile "C:UsersjoywDesktopScripts.zip"


          Note:The zip doesn't include the top folder itself. Make sure you include
          the trailing slash, e.g, I download the Scripts folder, we need to use Scripts/ in the apiUrl.






          share|improve this answer


























          • I need to download a folder.

            – Denis Koreyba
            Nov 27 '18 at 10:34











          • No, it's not what I asked for.

            – Denis Koreyba
            Nov 29 '18 at 9:36











          • @DenisKoreyba It does not download the folder?

            – Joy Wang
            Nov 29 '18 at 9:39














          1












          1








          1







          If you want to download file from web app, you could use this web app kudu api via powershell.



          Try the command below, it works fine on my side.



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))

          $apiUrl = "https://joywebapp2.scm.azurewebsites.net/api/vfs/site/wwwroot/Content/Site.css"
          Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo);"If-Match"="*"} -Method GET -ContentType "multipart/form-data" -OutFile "C:UsersjoywDesktoptest.css"


          Test result:



          enter image description here



          enter image description here



          Update:



          If you want to download a folder, you can use the Zip api in the doc I mentioned, it allows downloading folder as a zip file.



          Sample command:



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))

          $apiUrl = "https://joywebapp2.scm.azurewebsites.net/api/zip/site/wwwroot/Scripts/"
          Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo);"If-Match"="*"} -Method GET -ContentType "multipart/form-data" -OutFile "C:UsersjoywDesktopScripts.zip"


          Note:The zip doesn't include the top folder itself. Make sure you include
          the trailing slash, e.g, I download the Scripts folder, we need to use Scripts/ in the apiUrl.






          share|improve this answer















          If you want to download file from web app, you could use this web app kudu api via powershell.



          Try the command below, it works fine on my side.



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))

          $apiUrl = "https://joywebapp2.scm.azurewebsites.net/api/vfs/site/wwwroot/Content/Site.css"
          Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo);"If-Match"="*"} -Method GET -ContentType "multipart/form-data" -OutFile "C:UsersjoywDesktoptest.css"


          Test result:



          enter image description here



          enter image description here



          Update:



          If you want to download a folder, you can use the Zip api in the doc I mentioned, it allows downloading folder as a zip file.



          Sample command:



          $creds = Invoke-AzureRmResourceAction -ResourceGroupName joywebapp -ResourceType Microsoft.Web/sites/config -ResourceName joywebapp2/publishingcredentials -Action list -ApiVersion 2015-08-01 -Force
          $username = $creds.Properties.PublishingUserName
          $password = $creds.Properties.PublishingPassword
          $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username, $password)))

          $apiUrl = "https://joywebapp2.scm.azurewebsites.net/api/zip/site/wwwroot/Scripts/"
          Invoke-RestMethod -Uri $apiUrl -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo);"If-Match"="*"} -Method GET -ContentType "multipart/form-data" -OutFile "C:UsersjoywDesktopScripts.zip"


          Note:The zip doesn't include the top folder itself. Make sure you include
          the trailing slash, e.g, I download the Scripts folder, we need to use Scripts/ in the apiUrl.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 28 '18 at 6:56

























          answered Nov 27 '18 at 2:28









          Joy WangJoy Wang

          7,2832213




          7,2832213













          • I need to download a folder.

            – Denis Koreyba
            Nov 27 '18 at 10:34











          • No, it's not what I asked for.

            – Denis Koreyba
            Nov 29 '18 at 9:36











          • @DenisKoreyba It does not download the folder?

            – Joy Wang
            Nov 29 '18 at 9:39



















          • I need to download a folder.

            – Denis Koreyba
            Nov 27 '18 at 10:34











          • No, it's not what I asked for.

            – Denis Koreyba
            Nov 29 '18 at 9:36











          • @DenisKoreyba It does not download the folder?

            – Joy Wang
            Nov 29 '18 at 9:39

















          I need to download a folder.

          – Denis Koreyba
          Nov 27 '18 at 10:34





          I need to download a folder.

          – Denis Koreyba
          Nov 27 '18 at 10:34













          No, it's not what I asked for.

          – Denis Koreyba
          Nov 29 '18 at 9:36





          No, it's not what I asked for.

          – Denis Koreyba
          Nov 29 '18 at 9:36













          @DenisKoreyba It does not download the folder?

          – Joy Wang
          Nov 29 '18 at 9:39





          @DenisKoreyba It does not download the folder?

          – Joy Wang
          Nov 29 '18 at 9:39




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53483042%2fsave-azrwebapp-func-downloads-a-wrong-sourcepath%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Lallio

          Unable to find Lightning Node

          Futebolista