Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Issue] .NET Aspire - Bind Mount upload operation fails #4413

Open
1 task done
tommasodotNET opened this issue Oct 8, 2024 · 5 comments
Open
1 task done

[Issue] .NET Aspire - Bind Mount upload operation fails #4413

tommasodotNET opened this issue Oct 8, 2024 · 5 comments
Assignees
Labels

Comments

@tommasodotNET
Copy link

tommasodotNET commented Oct 8, 2024

Output from azd version
azd version 1.10.1 (commit 31409a3)

Describe the bug
I have the following aspire container resource, using a BindMount:

var dab = builder.AddContainer("dab", "mcr.microsoft.com/azure-databases/data-api-builder", "latest") 
    .WithHttpEndpoint(targetPort: 5000, name: "http")    
    .WithOtlpExporter()    
    .WithBindMount("./<PATH_TO_FILE>/dab-config.json", target: "/App/dab-config.json")

This is what running azd infra synth with the azd operations feature on will generate on Windows:

operations:
- type: FileShareUpload  
  description: Upload files for containerapp  
  config:    
    storageAccount: ${AZURE_VOLUMES_STORAGE_ACCOUNT}   
    fileShareName: ${SERVICE_CONTAINERAPP_FILE_SHARE_BM0_NAME}    
    path: C:\Users\tstocchi\AppData\Local\Temp\azd-provision3110193039\D:\src\<PATH_TO_FILE>\dab-config.json

Running the same command on WSL will generate this:

operations:
- type: FileShareUpload
  description: Upload files for dab
  config:
    storageAccount: ${AZURE_VOLUMES_STORAGE_ACCOUNT}
    fileShareName: ${SERVICE_DAB_FILE_SHARE_BM0_NAME}
    path: /mnt/d/src/<PATH_TO_FILE>/dab-config.json

On Windows, azd up will fail because the path for the file to be uploaded cannot be found. I think this might be cause by the fact that the path is formed as <TEMP_FOLDER>/<PATH_TO_FILE>/dab-config.json.

On WSL, azd up will fail because it uses the PUT verb, which is not supported:

ERROR: error executing step command 'provision': deployment failed: error running bind mount operation: error binding mount: error uplaoding file to file share: PUT https://<STORAGE_ACCOUNT_ENDPOINT>.file.core.windows.net/dab-bm0/
_____________________________________
RESPONSE 405: 405 The resource doesn't support specified Http Verb.
ERROR CODE: UnsupportedHttpVerb

To Reproduce

  • add the above code to a .NET Aspire project
  • activate the azd operations feature
  • run azd up (and azd infra synth to see the generated operations file)

Expected behavior
I expect the azd provision step to be able to upload the file referenced in the BindMount.

Environment
Information on your environment:
* .NET Aspire 8.2.0
* IDE and version : VS Code
* OS: Windows and WSL (Ubuntu 22.04.4 LTS)

@rajeshkamal5050
Copy link
Contributor

@vhvb1989 can you take a look?

@Zettersten
Copy link

Zettersten commented Oct 10, 2024

Same issue I think:

var builder = DistributedApplication.CreateBuilder(args);

// PG SQL container is configured with an auto-generated password by default
// and supports setting the default database name via an environment variable & running *.sql/*.sh scripts in a bind mount.
var databaseName = "keyval-db";

var databaseReference = builder.AddPostgres("keyval-storage")
    // Set the name of the default database to auto-create on container startup.
    .WithEnvironment("POSTGRES_DB", databaseName)
    // Mount the SQL scripts directory into the container so that the init scripts run.
    .WithBindMount("../Project/Database/Scripts", "/docker-entrypoint-initdb.d")
    // Add the default database to the application model so that it can be referenced by other resources.
    .AddDatabase(databaseName);

builder
    .AddProject<Project>("keyval-api")
    .WithExternalHttpEndpoints()
    .WithReference(databaseReference)
    .WaitFor(databaseReference);

builder.Build().Run();

At first I saw this error in the terminal:

Provisioning Azure resources (azd provision)
Provisioning Azure resources can take some time.

*Note: Your project has bind mounts.
  - azd operations (alpha feature) is required but disabled. You can enable azd operations by running: azd config set alpha.azd.operations on
Ignoring bind mounts.

Regardless, the env deployed correctly. However, the initdb part did work - so app failed.

I went back an ran azd config set alpha.azd.operations on and then azd up and got this error:

ERROR: error executing step command 'provision': deployment failed: error running bind mount operation: error binding mount: CreateFile C:\Users\Me\AppData\Local\Temp\azd-provision1183615301\E:\Prohect\Database\Scripts: The filename, directory name, or volume label syntax is incorrect.

@vhvb1989
Copy link
Member

Thank you for trying and reporting this.
I'll work in a fix.

@vhvb1989
Copy link
Member

Quick update. I couldn't reproduce using the mysql sample from aspire repo playground.
I tried with Windows.
I suspect there's something here related to using either symlinks or a drive different than C:/

When using a different drive, azd is using a temp folder in C:/ and fails to create the path to outside of C:/

Will try to repro using a non C:/ drive

@tommasodotNET
Copy link
Author

tommasodotNET commented Nov 9, 2024

Hi @vhvb1989,

beside the temp folder, there is also the fact then when I try to upload from the correct one, I get this error:

ERROR: error executing step command 'provision': deployment failed: error running bind mount operation: error binding mount: error uplaoding file to file share: PUT https://<STORAGE_ACCOUNT_ENDPOINT>.file.core.windows.net/dab-bm0/
_____________________________________
RESPONSE 405: 405 The resource doesn't support specified Http Verb.
ERROR CODE: UnsupportedHttpVerb

FYI, it is currently impossible to repro from the dev drive using WSL because of this: microsoft/WSL#12156. But the BadRequest thing happens on windows as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants