You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2026/05/20 15:38:18 UTC

(opendal) branch main updated: feat(services/azblob): add block copier (#7551)

This is an automated email from the ASF dual-hosted git repository.

Xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 7ed317ada feat(services/azblob): add block copier (#7551)
7ed317ada is described below

commit 7ed317ada086d439087cfd08a2aaed9e661108c2
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Wed May 20 23:38:11 2026 +0800

    feat(services/azblob): add block copier (#7551)
    
    * feat(services/azblob): add block copier
    
    * fix(services/azblob): sign copy source URL
    
    * fix(services/azblob): keep copy blob source unsigned
---
 .github/services/azblob/azurite_azblob/action.yml |   1 +
 core/core/src/raw/oio/copy/block_copy.rs          | 368 ++++++++++++++++++++++
 core/core/src/raw/oio/copy/mod.rs                 |   3 +
 core/services/azblob/src/backend.rs               |  21 +-
 core/services/azblob/src/copier.rs                | 134 ++++++++
 core/services/azblob/src/core.rs                  | 105 ++++++
 core/services/azblob/src/lib.rs                   |   1 +
 core/tests/behavior/async_copy.rs                 |   5 +-
 8 files changed, 626 insertions(+), 12 deletions(-)

diff --git a/.github/services/azblob/azurite_azblob/action.yml b/.github/services/azblob/azurite_azblob/action.yml
index 9a084231f..e45f4f949 100644
--- a/.github/services/azblob/azurite_azblob/action.yml
+++ b/.github/services/azblob/azurite_azblob/action.yml
@@ -41,4 +41,5 @@ runs:
         OPENDAL_AZBLOB_ENDPOINT=http://127.0.0.1:10000/devstoreaccount1
         OPENDAL_AZBLOB_ACCOUNT_NAME=devstoreaccount1
         OPENDAL_AZBLOB_ACCOUNT_KEY=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
+        OPENDAL_TEST_CAPABILITY_OVERRIDES=copy_can_multi=false
         EOF
diff --git a/core/core/src/raw/oio/copy/block_copy.rs b/core/core/src/raw/oio/copy/block_copy.rs
new file mode 100644
index 000000000..d04d2505a
--- /dev/null
+++ b/core/core/src/raw/oio/copy/block_copy.rs
@@ -0,0 +1,368 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::future::Future;
+use std::sync::Arc;
+
+use futures::FutureExt;
+use futures::select;
+use uuid::Uuid;
+
+use crate::raw::*;
+use crate::*;
+
+/// BlockCopy is used to implement [`oio::Copy`] based on block copy.
+///
+/// By implementing BlockCopy, services only need to provide service-specific
+/// block copy operations. [`BlockCopier`] will drive source metadata loading,
+/// block id generation, block queue, completion, and abort state.
+pub trait BlockCopy: Send + Sync + Unpin + 'static {
+    /// source_metadata returns source metadata for planning block copy.
+    ///
+    /// BlockCopier will call this API when source content length hint is not
+    /// provided.
+    fn source_metadata(&self) -> impl Future<Output = Result<Metadata>> + MaybeSend;
+
+    /// copy_once is used to copy the source object at once.
+    ///
+    /// BlockCopier will call this API when the source object can be copied
+    /// without starting block copy.
+    fn copy_once(&self) -> impl Future<Output = Result<()>> + MaybeSend;
+
+    /// copy_block copies one source range into one block.
+    fn copy_block(
+        &self,
+        block_id: Uuid,
+        range: BytesRange,
+    ) -> impl Future<Output = Result<()>> + MaybeSend;
+
+    /// complete_block completes the block copy with the ordered block id list.
+    fn complete_block(&self, block_ids: Vec<Uuid>) -> impl Future<Output = Result<()>> + MaybeSend;
+
+    /// abort_block cancels the pending block copy and purges intermediate state.
+    fn abort_block(&self, block_ids: Vec<Uuid>) -> impl Future<Output = Result<()>> + MaybeSend;
+}
+
+struct CopyInput<C: BlockCopy> {
+    copier: Arc<C>,
+    executor: Executor,
+    block_id: Uuid,
+    block_number: usize,
+    range: BytesRange,
+}
+
+impl<C: BlockCopy> Clone for CopyInput<C> {
+    fn clone(&self) -> Self {
+        Self {
+            copier: self.copier.clone(),
+            executor: self.executor.clone(),
+            block_id: self.block_id,
+            block_number: self.block_number,
+            range: self.range,
+        }
+    }
+}
+
+struct CopiedBlock {
+    block_id: Uuid,
+    block_number: usize,
+    size: u64,
+}
+
+/// BlockCopier implements [`oio::Copy`] based on block copy.
+pub struct BlockCopier<C: BlockCopy> {
+    copier: Arc<C>,
+    executor: Executor,
+
+    block_ids: Vec<(usize, Uuid)>,
+    scheduled_block_ids: Vec<Uuid>,
+    next_block_number: usize,
+    next_offset: u64,
+    source_size: Option<u64>,
+    copy_once_threshold: u64,
+    block_size: u64,
+    concurrent: usize,
+    completed: bool,
+
+    tasks: ConcurrentTasks<CopyInput<C>, CopiedBlock>,
+}
+
+impl<C: BlockCopy> BlockCopier<C> {
+    /// Create a new BlockCopier.
+    pub fn new(
+        info: Arc<AccessorInfo>,
+        inner: C,
+        source_content_length_hint: Option<u64>,
+        copy_once_threshold: u64,
+        block_size: u64,
+        concurrent: usize,
+    ) -> Self {
+        let copier = Arc::new(inner);
+        let executor = info.executor();
+        let concurrent = concurrent.max(1);
+
+        Self {
+            copier,
+            executor: executor.clone(),
+            block_ids: Vec::new(),
+            scheduled_block_ids: Vec::new(),
+            next_block_number: 0,
+            next_offset: 0,
+            source_size: source_content_length_hint,
+            copy_once_threshold,
+            block_size,
+            concurrent,
+            completed: false,
+
+            tasks: ConcurrentTasks::new(executor, concurrent, 8192, |input| {
+                Box::pin(async move {
+                    let size = input.range.size().expect("block copy range must be sized");
+                    let fut = input.copier.copy_block(input.block_id, input.range);
+
+                    let result = match input.executor.timeout() {
+                        None => fut.await.map(|_| CopiedBlock {
+                            block_id: input.block_id,
+                            block_number: input.block_number,
+                            size,
+                        }),
+                        Some(timeout) => {
+                            select! {
+                                result = fut.fuse() => {
+                                    result.map(|_| CopiedBlock {
+                                        block_id: input.block_id,
+                                        block_number: input.block_number,
+                                        size,
+                                    })
+                                }
+                                _ = timeout.fuse() => {
+                                    Err(Error::new(
+                                        ErrorKind::Unexpected, "copy block timeout")
+                                            .with_context("block_id", input.block_id.to_string())
+                                            .set_temporary())
+                                }
+                            }
+                        }
+                    };
+
+                    (input, result)
+                })
+            }),
+        }
+    }
+
+    async fn source_size(&mut self) -> Result<u64> {
+        match self.source_size {
+            Some(size) => Ok(size),
+            None => {
+                let size = self.copier.source_metadata().await?.content_length();
+                self.source_size = Some(size);
+                Ok(size)
+            }
+        }
+    }
+
+    async fn fill_tasks(&mut self, source_size: u64) -> Result<()> {
+        let mut scheduled = 0;
+
+        while self.next_offset < source_size
+            && self.tasks.has_remaining()
+            && scheduled < self.concurrent
+        {
+            let size = self.block_size.min(source_size - self.next_offset);
+            let range = BytesRange::new(self.next_offset, Some(size));
+
+            let input = CopyInput {
+                copier: self.copier.clone(),
+                executor: self.executor.clone(),
+                block_id: Uuid::new_v4(),
+                block_number: self.next_block_number,
+                range,
+            };
+
+            loop {
+                match self.tasks.execute(input.clone()).await {
+                    Ok(()) => break,
+                    Err(err) if err.is_temporary() => continue,
+                    Err(err) => return Err(err),
+                }
+            }
+
+            self.scheduled_block_ids.push(input.block_id);
+            self.next_offset += size;
+            self.next_block_number += 1;
+            scheduled += 1;
+
+            if self.tasks.has_result() {
+                break;
+            }
+        }
+
+        Ok(())
+    }
+}
+
+impl<C> oio::Copy for BlockCopier<C>
+where
+    C: BlockCopy,
+{
+    async fn next(&mut self) -> Result<Option<usize>> {
+        if self.completed {
+            return Ok(None);
+        }
+
+        let source_size = self.source_size().await?;
+
+        if self.block_ids.is_empty() && source_size <= self.copy_once_threshold {
+            self.copier.copy_once().await?;
+            self.completed = true;
+            return Ok(None);
+        }
+
+        self.fill_tasks(source_size).await?;
+
+        loop {
+            match self.tasks.next().await {
+                Some(Ok(result)) => {
+                    let size = result.size.try_into().map_err(|_| {
+                        Error::new(ErrorKind::Unexpected, "block copy size exceeds usize")
+                    })?;
+                    self.block_ids.push((result.block_number, result.block_id));
+                    return Ok(Some(size));
+                }
+                Some(Err(err)) if err.is_temporary() => continue,
+                Some(Err(err)) => return Err(err),
+                None => break,
+            }
+        }
+
+        if self.block_ids.len() != self.next_block_number {
+            return Err(Error::new(
+                ErrorKind::Unexpected,
+                "block copy numbers mismatch, please report bug to opendal",
+            )
+            .with_context("expected", self.next_block_number)
+            .with_context("actual", self.block_ids.len()));
+        }
+
+        self.block_ids
+            .sort_by_key(|(block_number, _)| *block_number);
+        let block_ids = self
+            .block_ids
+            .iter()
+            .map(|(_, block_id)| *block_id)
+            .collect();
+        self.copier.complete_block(block_ids).await?;
+        self.completed = true;
+        Ok(None)
+    }
+
+    async fn abort(&mut self) -> Result<()> {
+        self.tasks.clear();
+        if self.scheduled_block_ids.is_empty() {
+            self.completed = true;
+            return Ok(());
+        }
+
+        self.copier
+            .abort_block(self.scheduled_block_ids.clone())
+            .await?;
+        self.completed = true;
+        Ok(())
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use std::collections::HashMap;
+    use std::sync::Mutex;
+
+    use tokio::time::Duration;
+    use tokio::time::sleep;
+
+    use super::*;
+    use crate::raw::oio::Copy;
+
+    #[derive(Default)]
+    struct TestState {
+        ranges: HashMap<Uuid, BytesRange>,
+        completed_ranges: Vec<BytesRange>,
+    }
+
+    struct TestCopy {
+        state: Arc<Mutex<TestState>>,
+    }
+
+    impl BlockCopy for TestCopy {
+        async fn source_metadata(&self) -> Result<Metadata> {
+            Ok(Metadata::default().with_content_length(4))
+        }
+
+        async fn copy_once(&self) -> Result<()> {
+            Ok(())
+        }
+
+        async fn copy_block(&self, block_id: Uuid, range: BytesRange) -> Result<()> {
+            if range.offset() == 0 {
+                sleep(Duration::from_millis(50)).await;
+            }
+
+            self.state
+                .lock()
+                .expect("test state mutex poisoned")
+                .ranges
+                .insert(block_id, range);
+
+            Ok(())
+        }
+
+        async fn complete_block(&self, block_ids: Vec<Uuid>) -> Result<()> {
+            let mut state = self.state.lock().expect("test state mutex poisoned");
+            state.completed_ranges = block_ids
+                .into_iter()
+                .map(|block_id| state.ranges[&block_id])
+                .collect();
+            Ok(())
+        }
+
+        async fn abort_block(&self, _: Vec<Uuid>) -> Result<()> {
+            Ok(())
+        }
+    }
+
+    #[tokio::test]
+    async fn test_block_copier_completes_blocks_in_source_order() -> Result<()> {
+        let state = Arc::new(Mutex::new(TestState::default()));
+        let inner = TestCopy {
+            state: state.clone(),
+        };
+        let mut copier = BlockCopier::new(Arc::default(), inner, None, 0, 2, 2);
+
+        while copier.next().await?.is_some() {}
+
+        let completed_ranges = state
+            .lock()
+            .expect("test state mutex poisoned")
+            .completed_ranges
+            .clone();
+        assert_eq!(
+            completed_ranges,
+            vec![BytesRange::new(0, Some(2)), BytesRange::new(2, Some(2))]
+        );
+
+        Ok(())
+    }
+}
diff --git a/core/core/src/raw/oio/copy/mod.rs b/core/core/src/raw/oio/copy/mod.rs
index f61f400ed..822526c70 100644
--- a/core/core/src/raw/oio/copy/mod.rs
+++ b/core/core/src/raw/oio/copy/mod.rs
@@ -18,5 +18,8 @@
 mod api;
 pub use api::*;
 
+mod block_copy;
+pub use block_copy::*;
+
 mod multipart_copy;
 pub use multipart_copy::*;
diff --git a/core/services/azblob/src/backend.rs b/core/services/azblob/src/backend.rs
index 6383f99a1..a43771384 100644
--- a/core/services/azblob/src/backend.rs
+++ b/core/services/azblob/src/backend.rs
@@ -37,7 +37,11 @@ use sha2::Sha256;
 
 use super::AZBLOB_SCHEME;
 use super::config::AzblobConfig;
+use super::copier::AzblobCopiers;
+use super::copier::new_azblob_copier;
 use super::core::AzblobCore;
+use super::core::constants::AZBLOB_COPY_MAX_BLOCK_SIZE;
+use super::core::constants::AZBLOB_COPY_MIN_BLOCK_SIZE;
 use super::core::constants::X_MS_META_PREFIX;
 use super::core::constants::X_MS_VERSION_ID;
 use super::deleter::AzblobDeleter;
@@ -441,6 +445,9 @@ impl Builder for AzblobBuilder {
 
                             copy: true,
                             copy_with_if_not_exists: true,
+                            copy_can_multi: true,
+                            copy_multi_min_size: Some(AZBLOB_COPY_MIN_BLOCK_SIZE),
+                            copy_multi_max_size: Some(AZBLOB_COPY_MAX_BLOCK_SIZE),
 
                             list: true,
                             list_with_recursive: true,
@@ -481,7 +488,7 @@ impl Access for AzblobBackend {
     type Writer = AzblobWriters;
     type Lister = oio::PageLister<AzblobLister>;
     type Deleter = oio::BatchDeleter<AzblobDeleter>;
-    type Copier = ();
+    type Copier = AzblobCopiers;
 
     fn info(&self) -> Arc<AccessorInfo> {
         self.core.info.clone()
@@ -566,16 +573,10 @@ impl Access for AzblobBackend {
         from: &str,
         to: &str,
         args: OpCopy,
-        _opts: OpCopier,
+        opts: OpCopier,
     ) -> Result<(RpCopy, Self::Copier)> {
-        let resp = self.core.azblob_copy_blob(from, to, args).await?;
-
-        let status = resp.status();
-
-        match status {
-            StatusCode::ACCEPTED => Ok((RpCopy::default(), ())),
-            _ => Err(parse_error(resp)),
-        }
+        let copier = new_azblob_copier(self.core.clone(), from, to, args, opts)?;
+        Ok((RpCopy::default(), copier))
     }
 
     async fn presign(&self, path: &str, args: OpPresign) -> Result<RpPresign> {
diff --git a/core/services/azblob/src/copier.rs b/core/services/azblob/src/copier.rs
new file mode 100644
index 000000000..5cea31d9b
--- /dev/null
+++ b/core/services/azblob/src/copier.rs
@@ -0,0 +1,134 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::sync::Arc;
+
+use http::StatusCode;
+use uuid::Uuid;
+
+use super::core::AzblobCore;
+use super::core::constants::AZBLOB_COPY_MAX_BLOCK_SIZE;
+use super::core::constants::AZBLOB_COPY_MIN_BLOCK_SIZE;
+use super::core::constants::X_MS_VERSION_ID;
+use super::error::parse_error;
+use opendal_core::raw::oio::BlockCopy;
+use opendal_core::raw::*;
+use opendal_core::*;
+
+pub type AzblobCopiers = TwoWays<oio::OneShotCopier, oio::BlockCopier<AzblobCopier>>;
+
+pub fn new_azblob_copier(
+    core: Arc<AzblobCore>,
+    from: &str,
+    to: &str,
+    args: OpCopy,
+    opts: OpCopier,
+) -> Result<AzblobCopiers> {
+    let info = core.info.clone();
+    let copier = AzblobCopier {
+        core,
+        from: from.to_string(),
+        to: to.to_string(),
+        args,
+    };
+
+    let Some(chunk) = opts.chunk() else {
+        return Ok(TwoWays::One(oio::OneShotCopier::new(async move {
+            copier.copy_once().await?;
+            Ok(None)
+        })));
+    };
+
+    let block_size = chunk.clamp(AZBLOB_COPY_MIN_BLOCK_SIZE, AZBLOB_COPY_MAX_BLOCK_SIZE) as u64;
+
+    Ok(TwoWays::Two(oio::BlockCopier::new(
+        info,
+        copier,
+        opts.source_content_length_hint(),
+        block_size.saturating_sub(1),
+        block_size,
+        opts.concurrent(),
+    )))
+}
+
+pub struct AzblobCopier {
+    core: Arc<AzblobCore>,
+    from: String,
+    to: String,
+    args: OpCopy,
+}
+
+impl oio::BlockCopy for AzblobCopier {
+    async fn source_metadata(&self) -> Result<Metadata> {
+        let resp = self
+            .core
+            .azblob_get_blob_properties(&self.from, &OpStat::default())
+            .await?;
+
+        match resp.status() {
+            StatusCode::OK => {
+                let headers = resp.headers();
+                let mut meta = parse_into_metadata(&self.from, headers)?;
+                if let Some(version_id) = parse_header_to_str(headers, X_MS_VERSION_ID)? {
+                    meta.set_version(version_id);
+                }
+                Ok(meta)
+            }
+            _ => Err(parse_error(resp)),
+        }
+    }
+
+    async fn copy_once(&self) -> Result<()> {
+        let resp = self
+            .core
+            .azblob_copy_blob(&self.from, &self.to, self.args.clone())
+            .await?;
+
+        match resp.status() {
+            StatusCode::ACCEPTED => Ok(()),
+            _ => Err(parse_error(resp)),
+        }
+    }
+
+    async fn copy_block(&self, block_id: Uuid, range: BytesRange) -> Result<()> {
+        let resp = self
+            .core
+            .azblob_put_block_from_url(&self.from, &self.to, block_id, range)
+            .await?;
+
+        match resp.status() {
+            StatusCode::CREATED | StatusCode::OK => Ok(()),
+            _ => Err(parse_error(resp)),
+        }
+    }
+
+    async fn complete_block(&self, block_ids: Vec<Uuid>) -> Result<()> {
+        let resp = self
+            .core
+            .azblob_complete_copy_block_list(&self.to, block_ids, &self.args)
+            .await?;
+
+        match resp.status() {
+            StatusCode::CREATED | StatusCode::OK => Ok(()),
+            _ => Err(parse_error(resp)),
+        }
+    }
+
+    async fn abort_block(&self, _block_ids: Vec<Uuid>) -> Result<()> {
+        Ok(())
+    }
+}
diff --git a/core/services/azblob/src/core.rs b/core/services/azblob/src/core.rs
index 9ee707fd7..bc787c3bc 100644
--- a/core/services/azblob/src/core.rs
+++ b/core/services/azblob/src/core.rs
@@ -42,11 +42,19 @@ use opendal_core::raw::*;
 use opendal_core::*;
 
 pub mod constants {
+    pub const AZBLOB_COPY_MIN_BLOCK_SIZE: usize = 1;
+    // Put Block From URL supports blocks up to 4,000 MiB with API version
+    // 2020-04-08 and later.
+    //
+    // ref: <https://learn.microsoft.com/en-us/rest/api/storageservices/put-block-from-url>
+    pub const AZBLOB_COPY_MAX_BLOCK_SIZE: usize = 4000 * 1024 * 1024;
+
     // Indicates the Blob Storage version that was used to execute the request
     pub const X_MS_VERSION: &str = "x-ms-version";
 
     pub const X_MS_BLOB_TYPE: &str = "x-ms-blob-type";
     pub const X_MS_COPY_SOURCE: &str = "x-ms-copy-source";
+    pub const X_MS_COPY_SOURCE_RANGE: &str = "x-ms-source-range";
     pub const X_MS_BLOB_CACHE_CONTROL: &str = "x-ms-blob-cache-control";
     pub const X_MS_BLOB_CONDITION_APPENDPOS: &str = "x-ms-blob-condition-appendpos";
     pub const X_MS_META_PREFIX: &str = "x-ms-meta-";
@@ -479,6 +487,58 @@ impl AzblobCore {
         self.send(req).await
     }
 
+    pub fn azblob_put_block_from_url_request(
+        &self,
+        source: &str,
+        to: &str,
+        block_id: Uuid,
+        range: BytesRange,
+    ) -> Result<Request<Buffer>> {
+        let url = QueryPairsWriter::new(&self.build_path_url(to))
+            .push("comp", "block")
+            .push(
+                "blockid",
+                &percent_encode_path(&BASE64_STANDARD.encode(block_id.as_bytes())),
+            )
+            .finish();
+
+        let mut req = Request::put(&url)
+            .header(constants::X_MS_COPY_SOURCE, source)
+            .header(CONTENT_LENGTH, 0);
+
+        if !range.is_full() {
+            req = req.header(constants::X_MS_COPY_SOURCE_RANGE, range.to_header());
+        }
+
+        let req = self.insert_sse_headers(req);
+        let req = req
+            .extension(Operation::Copy)
+            .extension(ServiceOperation("PutBlockFromUrl"))
+            .body(Buffer::new())
+            .map_err(new_request_build_error)?;
+
+        Ok(req)
+    }
+
+    pub async fn azblob_put_block_from_url(
+        &self,
+        from: &str,
+        to: &str,
+        block_id: Uuid,
+        range: BytesRange,
+    ) -> Result<Response<Buffer>> {
+        let source = Request::get(self.build_path_url(from))
+            .extension(Operation::Copy)
+            .extension(ServiceOperation("GetBlob"))
+            .body(Buffer::new())
+            .map_err(new_request_build_error)?;
+        let source = self.sign_query(source).await?;
+        let source = source.uri().to_string();
+        let req = self.azblob_put_block_from_url_request(&source, to, block_id, range)?;
+        let req = self.sign(req).await?;
+        self.send(req).await
+    }
+
     fn azblob_complete_put_block_list_request(
         &self,
         path: &str,
@@ -528,6 +588,51 @@ impl AzblobCore {
         self.send(req).await
     }
 
+    fn azblob_complete_copy_block_list_request(
+        &self,
+        path: &str,
+        block_ids: Vec<Uuid>,
+        args: &OpCopy,
+    ) -> Result<Request<Buffer>> {
+        let url = format!("{}?comp=blocklist", &self.build_path_url(path));
+
+        let mut req = Request::put(&url);
+
+        if args.if_not_exists() {
+            req = req.header(IF_NONE_MATCH, "*");
+        }
+
+        let content = quick_xml::se::to_string(&PutBlockListRequest {
+            latest: block_ids
+                .into_iter()
+                .map(|block_id| BASE64_STANDARD.encode(block_id.as_bytes()))
+                .collect(),
+        })
+        .map_err(new_xml_serialize_error)?;
+
+        req = req.header(CONTENT_LENGTH, content.len());
+
+        let req = self.insert_sse_headers(req);
+        let req = req
+            .extension(Operation::Copy)
+            .extension(ServiceOperation("PutBlockList"))
+            .body(Buffer::from(Bytes::from(content)))
+            .map_err(new_request_build_error)?;
+
+        Ok(req)
+    }
+
+    pub async fn azblob_complete_copy_block_list(
+        &self,
+        path: &str,
+        block_ids: Vec<Uuid>,
+        args: &OpCopy,
+    ) -> Result<Response<Buffer>> {
+        let req = self.azblob_complete_copy_block_list_request(path, block_ids, args)?;
+        let req = self.sign(req).await?;
+        self.send(req).await
+    }
+
     pub fn azblob_head_blob_request(&self, path: &str, args: &OpStat) -> Result<Request<Buffer>> {
         let mut req = Request::head(self.build_path_url(path));
 
diff --git a/core/services/azblob/src/lib.rs b/core/services/azblob/src/lib.rs
index 6656b55c3..cde3b51f4 100644
--- a/core/services/azblob/src/lib.rs
+++ b/core/services/azblob/src/lib.rs
@@ -25,6 +25,7 @@ pub fn register_azblob_service(registry: &opendal_core::OperatorRegistry) {
 
 mod backend;
 mod config;
+mod copier;
 pub mod core;
 mod deleter;
 mod error;
diff --git a/core/tests/behavior/async_copy.rs b/core/tests/behavior/async_copy.rs
index 487d1833f..d043992a2 100644
--- a/core/tests/behavior/async_copy.rs
+++ b/core/tests/behavior/async_copy.rs
@@ -518,11 +518,12 @@ pub async fn test_copier_with_if_not_exists_to_existing_file(op: Operator) -> Re
     let (target_content, _) = gen_bytes(op.info().full_capability());
     op.write(&target_path, target_content.clone()).await?;
 
-    let err = op
+    let mut copier = op
         .copier_with(&source_path, &target_path)
         .if_not_exists(true)
         .await
-        .expect_err("copier must fail");
+        .expect("copier must be created");
+    let err = copier.next().await.expect_err("copier must fail");
     assert_eq!(err.kind(), ErrorKind::ConditionNotMatch);
 
     let current_content = op