Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/19/12 17:45:21 (13 years ago)
Author:
spimming
Message:

#1680:

  • Methods to create a deployment added
  • Download blob block from public blob container
  • Constants for deployment and storage api version added
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.CloudManager/3.3/Azure/ServiceManagementOperation.cs

    r7354 r7374  
    2424using System.IO;
    2525using System.Linq;
     26using System.Net;
    2627using System.Xml.Linq;
    2728using HeuristicLab.Clients.Hive.CloudManager.Model;
     
    185186    }
    186187
    187 
     188    public static string CreateDeployment(string subscriptionId, string thumbprint, string serviceName, string deploymentName, string deploymentSlot, string packageUrl, string configuration, string label, int instanceCount) {
     189      string uri = String.Format(Constants.URIDeploymentFormat, subscriptionId, serviceName, deploymentSlot);
     190      XElement xConfig = XElement.Parse(configuration);
     191      SetInstanceCount(xConfig, Constants.HLSlaveRoleName, instanceCount);
     192
     193      XDocument payload = CreateDeploymentPayload(deploymentName, packageUrl, xConfig, label);
     194      ServiceWebRequest operation = new ServiceWebRequest(thumbprint);
     195      string requestId = operation.Invoke(uri, payload);
     196      return requestId;
     197    }
     198
     199    public static string DownloadBlobAsString(Uri uri) {
     200      HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
     201      request.Headers.Add(Constants.HeaderVersionName, Constants.APIVersion20110818);
     202      request.Method = Constants.HttpMethodGET;
     203      request.ContentType = Constants.ContentTypeAppXml;
     204      string result = string.Empty;
     205      WebResponse response = request.GetResponse();
     206      using (StreamReader reader = new StreamReader(response.GetResponseStream())) {
     207        result = reader.ReadToEnd();
     208      }
     209      return result;
     210    }
    188211
    189212    #endregion
Note: See TracChangeset for help on using the changeset viewer.