Ejemplo n.º 1
0
        /// <summary>
        /// NB Not handling case where source immutable blob is deleted at same time as copy.
        /// NB Not using GetBlobReferenceFromServer as this requires a lot of complex exception handling.
        /// </summary>
        /// <param name="relativePath"></param>
        public async Task Execute(string relativePath)
        {
            try
            {
                var source = _SourceStorageAccountConfig.GetBlobDirect(relativePath, AccessCondition.GenerateIfExistsCondition());

                var destination = _DestinationStorageAccountConfig.GetBlobIndirect(relativePath);

                if (destination.Exists())
                {
                    return;
                }

                destination.StartCopy(source);
            }
            catch (Exception e)
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        public async Task Execute(string relativePath)
        {
            _Source = _SourceStorageAccountConfig.GetBlobDirect(relativePath);

            if (_Source == null)
            {
                return; //TODO log
            }
            try
            {
                await _Source.AcquireLeaseAsync(null); //Lease Id not used - cannot lease the source blob of a copy

                if (!_Source.Exists())
                {
                    return; //TODO log
                }
                _Destination = _DestinationStorageAccountConfig.GetBlobIndirect(relativePath);

                if (!_Destination.Exists())
                {
                    //Create on first copy
                    _Destination.StartCopy(_Source);
                    return; //TODO log
                }

                //Update
                if (await _Source.ContentSame(_Destination))
                {
                    return; //TODO log - already updated
                }
                var destinationLease = await _Destination.AcquireLeaseAsync(null);

                _Destination.StartCopy(_Source, destAccessCondition: AccessCondition.GenerateLeaseCondition(destinationLease));
            }
            finally
            {
                await _Source.ReleaseLease();

                await _Destination.ReleaseLease();
            }
        }