0
這裏是我使用部署在Azure中的服務代碼,使用Azure管理庫來部署服務。錯誤:「給定路徑的格式不受支持。」
internal async static Task DeployCloudService(this SubscriptionCloudCredentials credentials)
{
try
{
using (var _computeManagementClient = new ComputeManagementClient(credentials))
{
Console.WriteLine("Deploying a service...");
var storageConnectionString = await GetStorageAccountConnectionString(credentials);
var account = CloudStorageAccount.Parse(storageConnectionString);
var blobs = account.CreateCloudBlobClient();
var container = blobs.GetContainerReference(ConfigurationManager.AppSettings["containerName"]);
if (!container.Exists()) { Console.WriteLine("Container not found"); };
await container.SetPermissionsAsync(
new BlobContainerPermissions()
{
PublicAccess = BlobContainerPublicAccessType.Container
});
var blob = container.GetBlockBlobReference(
Path.GetFileName(ConfigurationManager.AppSettings["packageFilePath"]));
var blob1 = container.GetBlockBlobReference(
Path.GetFileName(ConfigurationManager.AppSettings["configFilePath"]));
await _computeManagementClient.Deployments.CreateAsync(ConfigurationManager.AppSettings["serviceName"],
DeploymentSlot.Production,
new DeploymentCreateParameters
{
Label = ConfigurationManager.AppSettings["label"],
Name = ConfigurationManager.AppSettings["serviceName"],
PackageUri = blob.Uri,
Configuration = File.ReadAllText((blob1.Uri).ToString()),
StartDeployment = true
});
Console.WriteLine("Deployment Done!!!");
}
}
catch (Exception e) {
throw;
}
}
的想法是,包和配置文件已經存在在斑點一些容器內,我可以當我使用部署我的服務Configuration = File.ReadAllText(ConfigurationManager.AppSettings["configFilePath"])
(從本地路徑獲取文件並按預期正常工作),但是因爲我不想這樣做,所以我嘗試使用Azure blob中的配置文件,但是File.ReadAllText
未使用我的文件的Uri,而我檢查是否正常並給出System.SystemException {System.NotSupportedException}
與base {"The given path's format is not supported."}
。(如查找字符串參數)
My Question is that how can we use the config file (.cscfg) from the server
有沒有像'DownloadText()'方法 – ashishraaj
肯定有:https://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storage.blob.cloudblockblob。 downloadtext.aspx –
那麼也許這不是正確的方法,無論如何謝謝@Gaurav。如果我有什麼,我會評論。 – ashishraaj