Provision-server-roles-sqlserver fails with MissingMethodException for MemoryCache..ctor
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 991
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 201
Description
## Description
`aspire deploy` fails at the `provision-server-roles-sqlserver` step with a `MissingMethodException` inside the Azure Deployment Script container. The SQL role was provisioned successfully on the first deploy and persists, so the app works — but every subsequent deploy fails at this step.
## Error
Error code = DeploymentScriptError
System.MissingMethodException: Method not found:
'Void Microsoft.Extensions.Caching.Memory.MemoryCache..ctor(
Microsoft.Extensions.Options.IOptions`1)'
at Microsoft.SqlServer.Management.AlwaysEncrypted.Management.SqlAKVProviderWithDisposableCache..ctor(TokenCredential tokenCredential)
at Microsoft.SqlServer.Management.AlwaysEncrypted.Management.AlwaysEncryptedManagement.SetCustomProvidersWithDisposableCache(Boolean useGlobalCredential)
at Microsoft.SqlServer.Management.PowerShell.Shared.AzureKeyVaultUtilities.RegisterCustomKeyStoreProviders(...)
at Microsoft.SqlServer.Management.PowerShell.GetScriptCommand.ProcessRecord()
at , /mnt/azscripts/azscriptinput/userscript.ps1: line 41
## Root Cause
The Azure Deployment Script container used for SQL role provisioning has a version conflict between the **SqlServer PowerShell module** and **Microsoft.Extensions.Caching.Memory**. The `MemoryCache` constructor signature the SqlServer module expects no longer exists in the version of `Microsoft.Extensions.Caching.Memory` loaded in the container.
## Reproduction
1. Create an Aspire app with `AddAzureSqlServer` and a project referencing the SQL database
2. Run `aspire deploy` — first deploy succeeds
3. Run `aspire deploy` again — `provision-server-roles-sqlserver` fails every time
## Environment
- Aspire CLI: latest (via `dotnet tool install -g aspire.cli`)
- Aspire SDK: 13.4.6
- .NET SDK: 10.0
- OS: Ubuntu (GitHub Actions runner)
## Workaround
We use `continue-on-error: true` on the deploy step and fall back to `az containerapp update` to manually point the container app at the latest ACR image.
Contributor guide
Research direction
Start by reproducing the repeated `aspire deploy` failure and inspect the Azure Deployment Script container, including the SqlServer PowerShell module and Microsoft.Extensions.Caching.Memory versions used around `/mnt/azscripts/azscriptinput/userscript.ps1:41`. Done means subsequent deploys complete the `provision-server-roles-sqlserver` step without the MissingMethodException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, csharp, powershell
- Domain
- cloud, database, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100