azure-dev icon indicating copy to clipboard operation
azure-dev copied to clipboard

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

Open tommasodotNET opened this issue 1 year ago • 4 comments

  • [x] Make sure you've installed the latest version using instructions in the wiki

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

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)

tommasodotNET avatar Oct 08 '24 08:10 tommasodotNET

@vhvb1989 can you take a look?

rajeshkamal5050 avatar Oct 10 '24 16:10 rajeshkamal5050

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.

Zettersten avatar Oct 10 '24 19:10 Zettersten

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

vhvb1989 avatar Oct 10 '24 20:10 vhvb1989

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

vhvb1989 avatar Oct 16 '24 00:10 vhvb1989

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: https://github.com/microsoft/WSL/issues/12156. But the BadRequest thing happens on windows as well.

tommasodotNET avatar Nov 09 '24 22:11 tommasodotNET

I started getting this error when running azd up and it coincided with enabling azd operations via azd config set alpha.azd.operations on. I disabled it with azd config set alpha.azd.operations off and now the deploy is working again. I do see the warning about the project having bind mounts, but do not experience any errors or issues that I can find as a result of this.

jamescarignan avatar Dec 04 '24 17:12 jamescarignan

@rajeshkamal5050 In the latest round of Aspire testing, this issue was encountered.

Repro Steps:

  1. Clone aspire-samples.
  2. Run command azd config set alpha.azd.operations on.
  3. Run command cd samples/Metrics.
  4. Run command azd init.
  5. Run command azd up.

Environment:

  • Sample: Metrics.
  • Branch: main.
  • Dotnet SDK version: 9.0.101
  • .NET Aspire: 9.0.0.
  • OS: Windows.
  • Azd version: azd version 1.12.0-beta.1-daily.4442669 (commit 9b60cbc2a703200eb04d325988dc359886b2dfcb).

Menghua1 avatar Dec 31 '24 09:12 Menghua1

@rajeshkamal5050 In the latest round of Aspire testing, this issue was encountered.

Repro Steps:

  1. Clone aspire-samples.
  2. Run command azd config set alpha.azd.operations on.
  3. Run command cd samples/Metrics.
  4. Run command azd init.
  5. Run command azd up.

Environment:

  • Sample: Metrics.
  • Branch: main.
  • Dotnet SDK version: 9.0.102
  • .NET Aspire: 9.0.0.
  • OS: Windows.
  • Azd version:azd version 1.12.0-beta.1-daily.4489231 (commit a6eb17988fc047579a8edaaa86f302f5f0ab4bb8).

Menghua1 avatar Jan 23 '25 10:01 Menghua1

@vhvb1989 can you check the above issue repro from @Menghua1. Pull it into the sprint if any fix needed.

rajeshkamal5050 avatar Feb 05 '25 07:02 rajeshkamal5050

@rajeshkamal5050 and @vhvb1989 Based on the latest code test, it works fine on the C drive in Windows but encounters the following error on the D drive: Image Repro Steps:

  1. Clone aspire-samples.
  2. Run command azd config set alpha.azd.operations on.
  3. Run command cd samples/Metrics.
  4. Run command azd init.
  5. Run command azd up.

Environment:

  • Sample: Metrics.
  • Branch: main.
  • Dotnet SDK version: 9.0.102
  • .NET Aspire: 9.0.0.
  • OS: Windows.
  • Azd version:azd version 1.13.0-beta.1-daily.4558764 (commit 908d8881e3708856e26913e04963a0f1980efc92).

Menghua1 avatar Feb 13 '25 08:02 Menghua1

Thanks for testing @Menghua1 , I have created a new fix: https://github.com/Azure/azure-dev/pull/4801 and tested that the Metrics sample works from a non C: directory.

vhvb1989 avatar Feb 15 '25 20:02 vhvb1989

@vhvb1989 Based on the latest code test, this issue has been fixed.😄

Menghua1 avatar Feb 20 '25 10:02 Menghua1