Esempio n. 1
0
        public void CanInitialize()
        {
            string content = 
                    @"<?xml version=""1.0"" encoding=""utf-8""?>
        <PublishData>
          <PublishProfile
            SchemaVersion=""2.0""
            PublishMethod=""AzureServiceManagementAPI"">
            <Subscription
              ServiceManagementUrl=""https://management.core.windows.net""
              Id="""+System.Guid.Empty+@"""
              Name=""MSDN""/>
          </PublishProfile>
        </PublishData>";

            string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
            string filename = "SubscriptionAttempt.xml";
            string filepath = Path.Combine(path, filename);

            System.IO.File.WriteAllText(filepath, content, System.Text.Encoding.UTF8);

            try
            {
                var attempt = new Subscription(filepath);
            }
            finally
            {
                if (File.Exists(filepath))
                {
                    File.Delete(filepath);
                }
            }
        }
Esempio n. 2
0
 public AzureRestClient(Subscription subscription, HttpClient httpClient, string baseUri, string servicePath)
 {
     Contract.Requires(subscription != null);
     Contract.Requires(httpClient != null);
     Subscription = subscription;
     _httpClient = httpClient;
     Uri = new Uri(baseUri + subscription.ID + "/" + servicePath);
 }
Esempio n. 3
0
 // We use the same HttpClient for all calls to the same subscription; this allows DNS and proxy details to be
 // cached across requests. Note that HttpClient allows parallel operations.
 internal static HttpClient CreateHttpClient (Subscription subscription, string msVersion, Func<IEnumerable<TraceListener>> listenerFunc)
 {
     var handler = new WebRequestHandler();
     handler.ClientCertificates.Add(subscription.ManagementCertificate);
     var logger = new LoggingHandler(handler, listenerFunc);
     var client = new HttpClient(logger, true);
     client.DefaultRequestHeaders.Add("x-ms-version", msVersion);
     return client;
 }