Example #1
0
        public DsmsStorageAccountFactory(StorageConnection connection) : base(connection)
        {
            this.traceSource = new FabricEvents.ExtensionsEvents(FabricEvents.Tasks.FabricDCA);

            var sourceLocation = connection.DsmsSourceLocation;

            this.traceSource.WriteInfo(TraceType, "Invoking ClientInitialize and creating DsmsStorageCredentials instance for source location: {0} and EndPointSuffix: {1}", sourceLocation, connection.DsmsEndpointSuffix);

            try
            {
                if (connection.DsmsAutopilotServiceName == null)
                {
                    CredentialManagementClient.Instance.ClientInitialize();
                }
                else
                {
                    CredentialManagementClient.Instance.ClientInitializeForAp(connection.DsmsAutopilotServiceName);
                }

                this.dsmsCredentials = DsmsStorageCredentials.GetStorageCredentials(sourceLocation);
            }
            catch (Exception ex)
            {
                this.traceSource.WriteExceptionAsError(TraceType, ex);
                throw;
            }
        }
        public DsmsAzureStorageHelper(string sourceLocation)
        {
            var configStore   = NativeConfigStore.FabricGetConfigStore();
            var ApServiceName = configStore.ReadUnencryptedString(BackupRestoreContants.BrsConfigSectionName, BackupRestoreContants.DsmsAutopilotServiceNameKeyName);

            if (string.IsNullOrEmpty(ApServiceName))
            {
                CredentialManagementClient.Instance.ClientInitialize();
            }
            else
            {
                CredentialManagementClient.Instance.ClientInitializeForAp(ApServiceName);
            }

            this.dsmsCredentials = DsmsStorageCredentials.GetStorageCredentials(sourceLocation);
        }