Esempio n. 1
0
        /// <summary>
        /// Get current storage account from azure subscription
        /// </summary>
        /// <returns>A storage account</returns>
        private CloudStorageAccount GetStorageAccountFromSubscription()
        {
            string CurrentStorageAccountName = CurrentContext.Subscription.GetProperty(AzureSubscription.Property.StorageAccount);

            if (string.IsNullOrEmpty(CurrentStorageAccountName))
            {
                throw new ArgumentException(Resources.DefaultStorageCredentialsNotFound);
            }
            else
            {
                WriteDebugLog(String.Format(Resources.UseCurrentStorageAccountFromSubscription, CurrentStorageAccountName, CurrentContext.Subscription.Name));

                try
                {
                    //The service channel initialized by subscription
                    return(CurrentContext.Subscription.GetCloudStorageAccount());
                }
                catch (System.ServiceModel.CommunicationException e)
                {
                    WriteVerboseWithTimestamp(Resources.CannotGetSotrageAccountFromSubscription);

                    if (e.IsNotFoundException())
                    {
                        //Repack the 404 error
                        string errorMessage = String.Format(Resources.CurrentStorageAccountNotFoundOnAzure, CurrentStorageAccountName, CurrentContext.Subscription.Name);
                        System.ServiceModel.CommunicationException exception = new System.ServiceModel.CommunicationException(errorMessage, e);
                        throw exception;
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
        public override void DidFinishLaunching(NSNotification notification)
        {
            var fileName = "../../../../../TestResult.txt";

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            using (TextWriter writer = File.CreateText(fileName)) {
                var x = new System.ServiceModel.CommunicationException();
                writer.WriteLine("Test Passed: " + x.ToString());
            }

            Environment.Exit(0);
        }