Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
413 stars 202 forks source link

[Issue] AZD Deploy Throws ArgumentNullException FromSystem.IO.BinaryWriter.Write() #4385

Closed sb-chericks closed 3 weeks ago

sb-chericks commented 1 month ago

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

Describe the bug Running my Aspire project locally works just great, all containers mount successfully and my 2 API applications run and respond correctly. I have run azd auth login, azd env select MY_ENV_NAME, and azd provision successfully.

However running azd deploy throws System.ArgumentNullException from System.IO.BinaryWriter.Write(String value). A full dump of the command logs are added below.

Running azd deploy --debug for the full debug logs doesn't add any useful information.

To Reproduce I'm not sure how to reproduce this.

Expected behavior Azd successfully deploys the built app to my Azure Environment

Environment Information on your environment:

Additional context

MSBUILD : error MSB4166: Child node "7" exited prematurely. Shutting down. Diagnostic information may be found in files in "C:\Users\chericks\AppData\Local\Temp\MSBuildTemp\" and will be named MSBuild_*.failure.txt. This location can be changed by setting the MSBUILDDEBUGPATH environment variable to a different directory.
MSBUILD : error MSB4166: C:\Users\chericks\AppData\Local\Temp\MSBuildTemp\MSBuild_pid-25732_c7b2ef6c9f844a5587b08fcffa7173cb.failure.txt:
MSBUILD : error MSB4166: UNHANDLED EXCEPTIONS FROM PROCESS 25732:
MSBUILD : error MSB4166: ====================<redacted>
MSBUILD : error MSB4166: 9/27/2024 10:58:41 AM
MSBUILD : error MSB4166: System.ArgumentNullException: Value cannot be null. (Parameter 'value')
MSBUILD : error MSB4166:    at System.ArgumentNullException.Throw(String paramName)
MSBUILD : error MSB4166:    at System.IO.BinaryWriter.Write(String value)
MSBUILD : error MSB4166:    at Microsoft.Build.Framework.TelemetryEventArgs.WriteToStream(BinaryWriter writer)
MSBUILD : error MSB4166:    at Microsoft.Build.Shared.LogMessagePacketBase.WriteToStream(ITranslator translator)
MSBUILD : error MSB4166:    at Microsoft.Build.Shared.LogMessagePacketBase.Translate(ITranslator translator)
MSBUILD : error MSB4166:    at Microsoft.Build.BackEnd.NodeEndpointOutOfProcBase.RunReadLoop(Stream localReadPipe, Stream localWritePipe, ConcurrentQueue`1 localPacketQueue, AutoResetEvent localPacketAvailable, AutoResetEvent localTerminatePacketPump)
MSBUILD : error MSB4166: ==================<redacted>
MSBUILD : error MSB4166:
MSBUILD : error MSB4166:
Build failed. Properties, Items, and Target results cannot be obtained. See details in stderr above.
rajeshkamal5050 commented 1 month ago

@sb-chericks thanks for reporting.

@vhvb1989 can you check if anything on azd side?

cc @davidfowl @mitchdenny

vhvb1989 commented 1 month ago

@sb-chericks can you share your AppHost code? It looks like there's some input missing during deploy

sb-chericks commented 1 month ago

Here is the content of my AppHost/Program.cs, let me know if you need to see something else. I've redacted my business namespaces and names.


using Microsoft.Extensions.Configuration;
using Projects;

const string applicationInsightsIdentifier = "ApplicationInsightsTelemetry";

var builder = DistributedApplication.CreateBuilder(args);
IResourceBuilder<IResourceWithConnectionString> identityDatabaseResource;
IResourceBuilder<IResourceWithConnectionString> applicationInsightsTelemetryResource;

if (builder.ExecutionContext.IsRunMode)
{
    builder.Configuration.AddUserSecrets<Program>();

    identityDatabaseResource = builder.AddSqlServer(
            "identity-context",
            builder.AddParameter("LocalDatabasePassword", true))
        .WithDataVolume("identityContextVolume").AddDatabase(Constants.IdentityContextIdentifier);

    applicationInsightsTelemetryResource = builder.AddConnectionString(
        applicationInsightsIdentifier,
        "APPLICATIONINSIGHTS_CONNECTION_STRING");
}
else
{
    identityDatabaseResource = builder.AddConnectionString(Constants.IdentityContextIdentifier);

    applicationInsightsTelemetryResource = builder.AddAzureApplicationInsights(applicationInsightsIdentifier);
}

var redisResource = builder.AddConnectionString(Constants.RedisIdentifier);
var gemDatabaseResource = builder.AddConnectionString(Constants.GemContextIdentifier);

var customerPrefetchResource = builder.AddConnectionString(Constants.ServiceBus.CustomerPrefetchSendIdentifier);
var marketingCampaignsResource = builder.AddConnectionString(Constants.ServiceBus.MarketingCampaignsSendIdentifier);

builder.AddProject<My_Business_Aspire_ServerServer>("server-server")
    .WithExternalHttpEndpoints()
    .WithReference(gemDatabaseResource)
    .WithReference(identityDatabaseResource)
    .WithReference(redisResource)
    .WithReference(customerPrefetchResource)
    .WithReference(marketingCampaignsResource)
    .WithReference(applicationInsightsTelemetryResource)
    .WithConfigurationParameters<IdentityConfiguration>()
    .WithConfigurationParameters<CrmConfiguration>()
    .WithConfigurationParameters<DialerConfiguration>()
    .WithConfigurationParameters<GemInstallerConfiguration>()
    .WithConfigurationParameters<DataStoreConfiguration>()
    .WithConfigurationParameters<DoubleBookerConfiguration>()
    .WithConfigurationParameters<GoogleConfiguration>()
    .WithConfigurationParameters<ServerServerConfiguration.ServerServerApplicationConfiguration>()
    .WithConfigurationParameters<ServerServerConfiguration.AzureAdConfiguration>()
    .WithConfigurationParameters<ServerServerConfiguration.QueueNameConfiguration>()
    .WithConfigurationParameters<ServerServerConfiguration.SignalRNegotiateConfiguration>();

// Some configs are being added twice.
// We need to figure out a way to just do it once for both projects.
builder.AddProject<My_Business_Aspire_ClientServer>("client-server")
    .WithExternalHttpEndpoints()
    .WithReference(gemDatabaseResource)
    .WithReference(identityDatabaseResource)
    .WithReference(redisResource)
    .WithConfigurationParameters<GemInstallerConfiguration>()
    .WithConfigurationParameters<DoubleBookerConfiguration>()
    .WithConfigurationParameters<DataStoreConfiguration>()
    .WithConfigurationParameters<GoogleConfiguration>()
    .WithConfigurationParameters<IdentityConfiguration>()
    .WithConfigurationParameters<CrmConfiguration>()
    .WithConfigurationParameters<DialerConfiguration>()
    .WithConfigurationParameters<ClientServerConfiguration.ClientServerApplicationConfiguration>()
    .WithConfigurationParameters<ClientServerConfiguration.CentersDialTimeMinMaxConfiguration>()
    .WithConfigurationParameters<ClientServerConfiguration.AccessTokenConfiguration>()
    .WithConfigurationParameters<ClientServerConfiguration.HostConfiguration>();

builder.Build().Run();
sb-chericks commented 1 month ago

I'm starting to suspect something is wrong with my dotnet installation. I'm running the latest 8.0.4 release, but my work partner was able to run azd deploy with my same repository with no problems. The educated guess of my colleague right now is that there is some parallelism issue with the dotnet build process that is failing.

I'm going to completely purge and reinstall dotnet and see if this helps.

rajeshkamal5050 commented 1 month ago

@sb-chericks any updates?

sb-chericks commented 1 month ago

Thanks for checking back @rajeshkamal5050.

No, this did not solve the problem. Of my 4 person team, 2 members were able to manually deploy the Aspire project to Azure, while 2 were not (same issue I detail above for both users).

We are all:

It must be some underlying issue with the installation of the software on the individual machine itself, or some artifact in the individual Windows user profile somewhere that is causing the issue.

The two of us that are failing have given up on this endeavor, since we nearly have our azure dev ops pipeline script finished and will be able to rely on that for deployments instead.

If you don't think this is worth pursuing, I can close the issue.

rajeshkamal5050 commented 1 month ago

@sb-chericks suspecting due to this Update your .NET SDK to 8.0.401. There was a regression with container publish.

Related issues

mitchdenny commented 3 weeks ago

I think we can close this. The resolution is updating the SDK.

sb-chericks commented 3 weeks ago

Agreed, we can close this. I haven't had time to confirm this was the issue for me, but will next week. My co-worker did confirm it fixed the identical issue for him.

Thanks so much for your help guys.