我想将Web应用程序部署的文件和文件夹从azure SCM下载到本地,是否可以通过使用FTP来减轻负载?如果是的话,请帮忙吗? [英] I want to download web app deployed files and folders from azure SCM to local, is it possible to down load with use of FTP? if yes then help please?

查看:125
本文介绍了我想将Web应用程序部署的文件和文件夹从azure SCM下载到本地,是否可以通过使用FTP来减轻负载?如果是的话,请帮忙吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用c#或Power Shell将Web App部署的文件和文件夹从Azure SCM下载到本地,是否可以使用FTP减轻负载?如果可以,请帮忙吗?

I want to download web app deployed files and folders from azure SCM to local using c# or power shell, is it possible to down load with use of FTP? if yes then help please?

我正在尝试使用下面的Power Shell代码来实现它.

I am trying to do it using below code of power shell.

#Login-AzAccount
#Get-AzureRmSubscription –SubscriptionName "Free Trial" | Select-AzureRmSubscription


#Get-AzureRmWebAppPublishingCredentials -resourceGroupName 'rg_rnd' -webAppName 'rnddev' -slotName ''


function Get-AzureRmWebAppPublishingCredentials($resourceGroupName, $webAppName, $slotName = $null){
if ([string]::IsNullOrWhiteSpace($slotName)){
$resourceType = "Microsoft.Web/sites/config"
$resourceName = "$webAppName/publishingcredentials"
}
else{
$resourceType = "Microsoft.Web/sites/slots/config"
$resourceName = "$webAppName/$slotName/publishingcredentials"
}
$publishingCredentials = Invoke-AzureRmResourceAction -ResourceGroupName $resourceGroupName -ResourceType $resourceType -ResourceName $resourceName -Action list -ApiVersion 2015-08-01 -Force
    return $publishingCredentials
}


#Get-KuduApiAuthorisationHeaderValue -resourceGroupName 'rg_rnd' -webAppName 'rnddev' -slotName ''


function Get-KuduApiAuthorisationHeaderValue($resourceGroupName, $webAppName, $slotName = $null){
    $publishingCredentials = Get-AzureRmWebAppPublishingCredentials $resourceGroupName $webAppName $slotName
    return ("Basic {0}" -f [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $publishingCredentials.Properties.PublishingUserName, $publishingCredentials.Properties.PublishingPassword))))
}


#Download-FileFromWebApp -resourceGroupName 'rg_rnd' -webAppName 'rnddev' -slotName '' -kuduPath '' -localPath "C:Temp"


function Download-FileFromWebApp($resourceGroupName, $webAppName, $slotName = "", $kuduPath, $localPath){


    $kuduApiAuthorisationToken = Get-KuduApiAuthorisationHeaderValue $resourceGroupName $webAppName $slotName
    #$localTemp = "http://$webAppName.scm.azurewebsites.net/api/vfs/site/Temp/"
    if ($slotName -eq ""){
        $kuduApiUrl = "https://$webAppName.scm.azurewebsites.net/api/vfs/site/wwwroot/bin/$kuduPath"
    }
    else{
        $kuduApiUrl = "https://$webAppName`-$slotName.scm.azurewebsites.net/api/vfs/site/wwwroot/$kuduPath"
    }
    $virtualPath = $kuduApiUrl.Replace(".scm.azurewebsites.", ".azurewebsites.").Replace("/api/vfs/site/wwwroot", "")
    Write-Host " Downloading File from WebApp. Source: '$virtualPath'. Target: '$localPath'..." -ForegroundColor DarkGray    
    
  
    Invoke-RestMethod -Uri $kuduApiUrl `
                        -Headers @{"Authorization"=$kuduApiAuthorisationToken;"If-Match"="*"} `
                        -Method GET `
                       -OutFile $localPath ` 
                       -ContentType "application/x-msdownload"
}


我遇到错误,我的机器拥有完全访问权限

I am getting below error, I have full access in my machine

 

推荐答案

You can copy files via FTP, this includes both the files that are deployed, and the repository and deployment related files. See, Accessing files via ftp - https://github.com/projectkudu/kudu/wiki/Accessing-files-via-ftp (manually) for more details.

Azure PowerShell示例 .

Azure PowerShell samples for Azure App Service Web Apps can be found in the Azure PowerShell samples.

 

如果您的要求适合,则可以通过Kudu手动上传/下载文件和文件夹.看, 下载文件和文件夹 以获取更多详细信息.

If your requirement fits, you could manually upload/download files and folders through Kudu. See, Download files and folder for more details.


T Kudu VFS API允许您上传和下载文件,获取列表目录中的文件,创建目录以及从Azure App的虚拟文件系统中删除文件 服务;并使用PowerShell调用它.在下面的链接中查看一些示例: 


The Kudu VFS API allows you to upload and download files, get a list of files in a directory, create directories, and delete files from the virtual file system of an Azure App Service; and use PowerShell to call it. Checkout the link below for a few samples: 

https://github .com/projectkudu/kudu/wiki/REST-API#vfs

https://github.com/projectkudu/kudu/wiki/REST-API#vfs

确保您具有管理员权限订阅.


这篇关于我想将Web应用程序部署的文件和文件夹从azure SCM下载到本地,是否可以通过使用FTP来减轻负载?如果是的话,请帮忙吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆