本文整理汇总了C#中IServiceManagement.GetStorageService方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceManagement.GetStorageService方法的具体用法?C# IServiceManagement.GetStorageService怎么用?C# IServiceManagement.GetStorageService使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceManagement
的用法示例。
在下文中一共展示了IServiceManagement.GetStorageService方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetCurrentCloudStorageAccount
public static CloudStorageAccount GetCurrentCloudStorageAccount(IServiceManagement channel, SubscriptionData subscriptionData)
{
if (String.IsNullOrEmpty(subscriptionData.CurrentStorageAccount))
{
return null;
}
if (subscriptionData.CurrentCloudStorageAccount != null)
{
return subscriptionData.CurrentCloudStorageAccount;
}
CloudStorageAccount currentStorage = null;
using (new OperationContextScope(channel.ToContextChannel()))
{
var storageService = channel.GetStorageService(subscriptionData.SubscriptionId, subscriptionData.CurrentStorageAccount);
var storageServiceKeys = channel.GetStorageKeys(subscriptionData.SubscriptionId, subscriptionData.CurrentStorageAccount);
if (storageService != null && storageServiceKeys != null)
{
string connectionString = General.BuildConnectionString("https", storageService.ServiceName, storageServiceKeys.StorageServiceKeys.Primary, storageService.StorageServiceProperties.Endpoints[0].Replace("http://", "https://"), storageService.StorageServiceProperties.Endpoints[2].Replace("http://", "https://"), storageService.StorageServiceProperties.Endpoints[1].Replace("http://", "https://"));
currentStorage = CloudStorageAccount.Parse(connectionString);
}
}
subscriptionData.CurrentCloudStorageAccount = currentStorage;
return currentStorage;
}
示例2: UploadPackageToBlob
public static Uri UploadPackageToBlob(IServiceManagement channel, string storageName, string subscriptionId, string packagePath)
{
StorageService storageKeys = channel.GetStorageKeys(subscriptionId, storageName);
string primary = storageKeys.StorageServiceKeys.Primary;
storageKeys = channel.GetStorageService(subscriptionId, storageName);
EndpointList endpoints = storageKeys.StorageServiceProperties.Endpoints;
string str = ((List<string>)endpoints).Find((string p) => p.Contains(".blob."));
return AzureBlob.UploadFile(storageName, primary, str, packagePath);
}
示例3: UploadPackageToBlob
public static Uri UploadPackageToBlob(IServiceManagement channel, string storageName, string subscriptionId, string packagePath, BlobRequestOptions blobRequestOptions)
{
StorageService storageService = channel.GetStorageKeys(subscriptionId, storageName);
string storageKey = storageService.StorageServiceKeys.Primary;
storageService = channel.GetStorageService(subscriptionId, storageName);
string blobEndpointUri = storageService.StorageServiceProperties.Endpoints[0];
return UploadFile(storageName, CreateHttpsEndpoint(blobEndpointUri), storageKey, packagePath, blobRequestOptions);
}
示例4: DeletePackageFromBlob
public static void DeletePackageFromBlob(IServiceManagement channel, string storageName, string subscriptionId, Uri packageUri)
{
var storageService = channel.GetStorageKeys(subscriptionId, storageName);
var storageKey = storageService.StorageServiceKeys.Primary;
storageService = channel.GetStorageService(subscriptionId, storageName);
var blobStorageEndpoint = new Uri(storageService.StorageServiceProperties.Endpoints.Find(p => p.Contains(BlobEndpointIdentifier)));
var credentials = new StorageCredentials(storageName, storageKey);
var client = new CloudBlobClient(blobStorageEndpoint, credentials);
ICloudBlob blob = client.GetBlobReferenceFromServer(packageUri);
blob.DeleteIfExists();
}
示例5: DeletePackageFromBlob
public static void DeletePackageFromBlob(IServiceManagement channel, string storageName, string subscriptionId, Uri packageUri)
{
StorageService storageKeys = channel.GetStorageKeys(subscriptionId, storageName);
string primary = storageKeys.StorageServiceKeys.Primary;
storageKeys = channel.GetStorageService(subscriptionId, storageName);
EndpointList endpoints = storageKeys.StorageServiceProperties.Endpoints;
string str = ((List<string>)endpoints).Find((string p) => p.Contains(".blob."));
StorageCredentialsAccountAndKey storageCredentialsAccountAndKey = new StorageCredentialsAccountAndKey(storageName, primary);
CloudBlobClient cloudBlobClient = new CloudBlobClient(str, storageCredentialsAccountAndKey);
CloudBlob blobReference = cloudBlobClient.GetBlobReference(packageUri.AbsoluteUri);
blobReference.DeleteIfExists();
}
示例6: SetCurrentCloudStorageAccount
private static void SetCurrentCloudStorageAccount(IServiceManagement channel, SubscriptionData subscriptionData)
{
CloudStorageAccount currentStorage = null;
using (new OperationContextScope((IContextChannel)channel))
{
var storageService = channel.GetStorageService(
subscriptionData.SubscriptionId,
subscriptionData.CurrentStorageAccount);
var storageServiceKeys = channel.GetStorageKeys(
subscriptionData.SubscriptionId,
subscriptionData.CurrentStorageAccount);
if (storageService != null && storageServiceKeys != null)
{
currentStorage = new CloudStorageAccount(new StorageCredentials(
storageService.ServiceName,
storageServiceKeys.StorageServiceKeys.Primary),
General.CreateHttpsEndpoint(storageService.StorageServiceProperties.Endpoints[0]),
General.CreateHttpsEndpoint(storageService.StorageServiceProperties.Endpoints[1]),
General.CreateHttpsEndpoint(storageService.StorageServiceProperties.Endpoints[2]));
}
}
subscriptionData.CurrentCloudStorageAccount = currentStorage;
}
示例7: PerformOperation
protected override void PerformOperation(IServiceManagement channel)
{
if (!string.IsNullOrEmpty(HostedServiceName))
{
if (!string.IsNullOrEmpty(ShowDeploymentString))
{
bool result = false;
if (!bool.TryParse(ShowDeploymentString, out result))
{
Console.WriteLine("show-deployments is not a boolean type.");
Console.WriteLine("Getting HostedService");
}
else if (result == true)
{
Console.WriteLine("Getting detailed HostedService");
}
var service = channel.GetHostedServiceWithDetails(SubscriptionId, HostedServiceName, result);
Utility.LogObject(service);
}
else
{
Console.WriteLine("Getting HostedService");
var service = channel.GetHostedService(SubscriptionId, HostedServiceName);
Utility.LogObject(service);
}
}
else if(!string.IsNullOrEmpty(StorageServiceName))
{
Console.WriteLine("Getting StorageService");
var service = channel.GetStorageService(SubscriptionId, StorageServiceName);
Utility.LogObject(service);
}
else if (!string.IsNullOrEmpty(AffinityGroupName))
{
Console.WriteLine("Getting AffinityGroup");
var service = channel.GetAffinityGroup(SubscriptionId, AffinityGroupName);
Utility.LogObject(service);
}
}