以编程方式删除文件并将其上传到Azure Webapp本地存储 [英] Delete and upload files into Azure webapp local storage programatically
问题描述
我已将网站部署到Azure中,并且我想从c#桌面应用程序以编程方式访问此路径:"D:\ home \ site \ app",并删除所有文件并以编程方式上传新文件.
我已经搜索并找到了很多方法,但是所有方法都是用于AzureStorage
或使用Kudu consol
或FTP
,而我真正想要的是访问以编程方式部署网站的本地存储,并以编程方式对文件进行一些编辑./p>
I've deployed a website into Azure and i want to access programaticaly this path : "D:\home\site\app" from a c# desktop application and delete all files and upload new ones programatically.
i have searched and found many ways but all are for AzureStorage
or using Kudu consol
or FTP
while what i realy want is to access the local storage where the website is deployed programatiacally, and make some edits on files programatically.
推荐答案
当然,站点控制管理器(Kudu)具有一个API,即VFS API: https://github.com/projectkudu/kudu/wiki/REST/API# vfs
Sure thing, the Site Control Manager (Kudu) has an API for that, the VFS API: https://github.com/projectkudu/kudu/wiki/REST-API#vfs
您可以使用以下任意一种进行身份验证:
You can use either of these for authentication:
- 您从STS获得的
Bearer
令牌( ARMClient 中的参考实现) - 站点级别的凭据(在您的 Web App→属性下的丑陋的凭据)
- Git/FTP凭据(订阅级别)
- A
Bearer
token that you obtain from the STS (reference implementation in ARMClient) - Site-level credentials (the long ugly ones under your Web App → Properties)
- Git/FTP credentials (subscription level)
用法示例(使用网站级别的凭据):
Sample usage (using site-level credentials):
# Line breaks brutally used to improve readability
# /api/vfs/ is d:\home
# Append path as necessary, i.e. /api/vfs/site/app
$ curl -k https://$are-we-eating-too-much-garlic-as-a-people:6sujXXX
XXXXXXq7Zc@are-we-eating-too-much-garlic-as-a-people.scm.azurewebsites.net
/api/vfs/site/wwwroot/ill-grab-this-file-over-vfs-api.txt
There, i did it.
我在这里假设您想从外界做所有这一切-因为您没有明确声明否则.
I'm assuming here that you want to do all that from the outside world - since you don't clearly state otherwise.
这篇关于以编程方式删除文件并将其上传到Azure Webapp本地存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!