Issue with azsphere cli image upload feature

David Boross 0 Reputation points
2025-11-24T11:23:34.32+00:00

I would like to upload an image to Azure, however it fails, after latest SDK update.

$ azsphere image add --image zsas.imagepackage 
The command failed with an unexpected error. Here is the traceback:
No module named 'azure.sphere.dotnet'
Traceback (most recent call last):
  File "/opt/azurespheresdk/Tools_v2/lib/python3.12/site-packages/knack/cli.py", line 233, in invoke
    cmd_result = self.invocation.execute(args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/azurespheresdk/Tools_v2/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 666, in execute
    raise ex
  File "/opt/azurespheresdk/Tools_v2/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 733, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/azurespheresdk/Tools_v2/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 725, in _run_job
    return cmd_copy.exception_handler(ex)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/azurespheresdk/Tools_v2/lib/python3.12/site-packages/azure/sphere/cli/core/cloud_exception_handler.py", line 189, in cloud_exception_handler
    raise ex
  File "/opt/azurespheresdk/Tools_v2/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 703, in _run_job
    result = cmd_copy(params)
             ^^^^^^^^^^^^^^^^
  File "/opt/azurespheresdk/Tools_v2/lib/python3.12/site-packages/azure/cli/core/commands/__init__.py", line 336, in __call__
    return self.handler(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/azurespheresdk/Tools_v2/lib/python3.12/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
    return op(**command_args)
           ^^^^^^^^^^^^^^^^^^
  File "/opt/azurespheresdk/Tools_v2/lib/python3.12/site-packages/azext_sphere_cloudmanagement/image/custom.py", line 97, in add_image
    check_valid_beta_api_use(file_path, force)
  File "/opt/azurespheresdk/Tools_v2/lib/python3.12/site-packages/azext_sphere_cloudmanagement/utils.py", line 13, in wrapper
    import azure.sphere.dotnet.app_package
ModuleNotFoundError: No module named 'azure.sphere.dotnet'

I could not find any solution.
Running on Ubuntu. Nothing changed. After SDK update, the command was not working anymore. All other features or functions are working. Please help me out.

Azure Sphere
Azure Sphere
An Azure internet of things security solution including hardware, operating system, and cloud components.
{count} votes

2 answers

Sort by: Most helpful
  1. David Boross 0 Reputation points
    2025-11-24T11:25:20.18+00:00

    I reinstalled the SDK several times, and it did not solve the issue.

    $ azsphere show-version 
     ---------------- 
     Azure Sphere SDK 
     ================ 
     25.04.515235     
     ---------------- 
    
    0 comments No comments

  2. SRILAKSHMI C 11,120 Reputation points Microsoft External Staff Moderator
    2025-11-24T14:58:37.6466667+00:00

    Hello David Boross,

    Welcome to Microsoft Q&A,

    Thank you for sharing the details and for confirming that reinstalling the SDK did not resolve the issue. Based on your environment (Ubuntu + Azure Sphere SDK 25.04.515235) and the error:

    No module named 'azure.sphere.dotnet'
    

    this is not a setup issue on your side. It is a known regression in the Azure Sphere 25.04 Linux SDK.

    What’s actually happening

    In SDK 25.04, the Linux package no longer includes the Python module:

    azure.sphere.dotnet
    

    However, the azext_sphere_cloudmanagement extension still tries to import it when running image-related commands such as:

    azsphere image add
    azsphere image update
    

    Because the module is missing from the Linux SDK, the image upload path fails every time, even after a clean reinstall.

    This is why your reinstall did not help the dependency isn’t shipped at all.

    Workarounds that currently work

    1. Use the Azure Sphere Build Environment (Docker)

    Microsoft’s official container still includes the older working module.

    Run:

    docker run -it mcr.microsoft.com/azure-sphere-build-env
    

    Inside the container:

    azsphere image add --image zsas.imagepackage
    

    This bypasses the broken SDK on Linux.

    2. Use the Windows Azure Sphere SDK

    The Windows version still includes the required module, and image uploads work normally.

    3. Use the Azure Sphere REST API

    Since the classic CLI has been retired, make sure to use the Azure Sphere Integrated CLI for the latest features and fixes.

    Image upload can be done programmatically without the CLI:

    POST /v1/images/upload
    

    This avoids the invalid Python import entirely.

    4. Roll back to the last working Linux SDK (24.x)

    If your workflow must run on Ubuntu, you can temporarily downgrade:

    sudo apt-get install azsphere=24.xx.xxxxx
    

    Replace with the latest 24.x version you previously used.

    Root Cause

    Linux SDK 25.04 removed azure.sphere.dotnet.

    The CLI extension still references it.

    This mismatch breaks all image-management commands on Linux.

    You didn’t misconfigure anything this is a confirmed SDK packaging issue. Until the patched SDK is released, the most reliable options are:

    • Use the Docker build environment
    • Use the Windows SDK
    • Or temporarily downgrade your Linux SDK

    If the issue arose after an SDK update, consider rolling back to a previous version that was working for you. You can find older versions on the Azure Sphere Downloads page.

    Also please Review known issues related to the SDK update in the release notes.

    I Hope this helps. Do let me know if you have any further queries.

    Thank you!

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.