public static void MapToProperty(ConnectionInfo existingInfo, string key, string value)
        {
            if ("primarykey".Equals(key))
            {
                existingInfo.PrimaryKey = value;
                return;
            }

            if ("secondarykey".Equals(key))
            {
                existingInfo.SecondaryKey = value;
                return;
            }

            if ("uri".Equals(key))
            {
                existingInfo.URI = value;
                return;
            }

            if ("storageaccountname".Equals(key))
            {
                existingInfo.StorageAccountName = value;
                return;
            }

            throw new ArgumentException(
                string.Format("The connection info '{0}' was not expected and is not understood.", key));
        }
        public static ConnectionInfo Parse(string connectionInfo)
        {
            var info = new ConnectionInfo();

            if (!string.IsNullOrWhiteSpace(connectionInfo))
            {
                string[] propertyPairs = connectionInfo.Split(new[] {'&'}, StringSplitOptions.RemoveEmptyEntries);
                foreach (string propertyPair in propertyPairs)
                {
                    string[] optionPairParts = propertyPair.Split(new[] {'='}, StringSplitOptions.RemoveEmptyEntries);
                    if (optionPairParts.Length == 2)
                    {
                        MapToProperty(info, optionPairParts[0].Trim().ToLowerInvariant(), optionPairParts[1].Trim());
                    }
                    else
                    {
                        throw new ArgumentException(
                            string.Format(
                                "Unable to parse connection info which should be in the form of 'property=value&nextproperty=nextValue'. The property '{0}' was not properly constructed",
                                propertyPair));
                    }
                }
            }

            return info;
        }
        public override ProvisionAddOnResult Provision(AddonProvisionRequest request)
        {
            var provisionResult = new ProvisionAddOnResult("");
            var manifest = request.Manifest;
            var inputDevParams = request.DeveloperParameters;
            try
            {
                // parse required options here, use developer options class to do so.
                var manifestProperties = manifest.GetProperties();
                // Developer Options will be instantiated first time here (hence, null).
                var devParams = DeveloperParameters.Parse(inputDevParams,manifestProperties);
                // establish MSFT Azure Storage client
                var client = EstablishClient(devParams);

                // ok now we need to understand what the developer wants to do.
                // ------------------------------------------------------------
                // logic:
                //    - if the developer wishes to create a storage account, we go that route first
                //    - if a storage account exists, test it (including above)
                //    - create the blob container
                // ------------------------------------------------------------
                var parameters = CreateStorageAccountParameters(devParams);
                var mResponse = client.StorageAccounts.Create(parameters);
                do
                {
                    StorageAccountGetResponse verificationResponse = client.StorageAccounts.Get(parameters.Name);

                    if (verificationResponse.StorageAccount.Properties.Status.Equals(StorageAccountStatus.Created))
                    {
                        StorageAccountGetResponse azureconnectioninfo =
                            client.StorageAccounts.Get(devParams.StorageAccountName);
                        StorageAccountGetKeysResponse keysForStorageUnit =
                            client.StorageAccounts.GetKeys(devParams.StorageAccountName);

                        var connectionInfo = new ConnectionInfo
                        {
                            PrimaryKey = keysForStorageUnit.PrimaryKey,
                            SecondaryKey = keysForStorageUnit.SecondaryKey,
                            StorageAccountName = azureconnectioninfo.StorageAccount.Name,
                            URI = keysForStorageUnit.Uri.ToString()
                        };
                        provisionResult.ConnectionData = connectionInfo.ToString();
                        // deprovision request of storage account was successful.
                        provisionResult.IsSuccess = true;
                        break;
                    }
                    Thread.Sleep(TimeSpan.FromSeconds(10d));
                } while (true);
            }
            catch (Exception e)
            {
                provisionResult.EndUserMessage = e.Message;
            }

            return provisionResult;
        }