{
  "id": "cloud/azure-app-service-connection-string-format",
  "signature": "System.InvalidOperationException: The ConnectionString 'DefaultConnection' has an invalid format. Expected format: 'Server=tcp:...;Database=...;User ID=...;Password=...;'",
  "signature_zh": "System.InvalidOperationException：连接字符串 'DefaultConnection' 格式无效。预期格式：'Server=tcp:...;Database=...;User ID=...;Password=...;'",
  "regex": "invalid format.*ConnectionString.*Expected format.*Server=",
  "domain": "cloud",
  "category": "config_error",
  "subcategory": null,
  "root_cause": "Azure App Service connection strings stored in app settings often have incorrect syntax (e.g., missing semicolons, wrong key names, or using non-SQL Server format for SQL Database).",
  "root_cause_type": "generic",
  "root_cause_zh": "Azure App Service 应用设置中存储的连接字符串通常语法错误（例如缺少分号、键名错误或对 SQL 数据库使用了非 SQL Server 格式）。",
  "versions": [
    {
      "version": "Azure App Service Windows",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "Azure App Service Linux",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": ".NET 8",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "Adding extra quotes around the connection string in app settings causes parsing errors.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Using Key Vault references without proper syntax like @Microsoft.KeyVault(SecretUri=...) results in the raw reference string being used as the connection string.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Copying a connection string from SQL Server Management Studio that includes 'Trusted_Connection=True' fails because Azure SQL requires SQL authentication.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use the correct format for Azure SQL Database in app settings: Server=tcp:<server>.database.windows.net,1433;Database=<db>;User ID=<user>@<server>;Password=<password>;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
      "success_rate": 0.95,
      "how": "Use the correct format for Azure SQL Database in app settings: Server=tcp:<server>.database.windows.net,1433;Database=<db>;User ID=<user>@<server>;Password=<password>;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
      "condition": "",
      "sources": []
    },
    {
      "action": "Retrieve the connection string from the Azure Portal: go to your SQL Database -> Connection strings -> ADO.NET, then copy the exact string and paste it into App Service's 'Connection strings' section, selecting 'SQLAzure' as the type.",
      "success_rate": 0.9,
      "how": "Retrieve the connection string from the Azure Portal: go to your SQL Database -> Connection strings -> ADO.NET, then copy the exact string and paste it into App Service's 'Connection strings' section, selecting 'SQLAzure' as the type.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a Key Vault reference with proper syntax: @Microsoft.KeyVault(SecretUri=https://myvault.vault.azure.net/secrets/myconnectionstring/). Ensure the App Service has 'Key Vault Secrets User' role on the vault.",
      "success_rate": 0.85,
      "how": "Use a Key Vault reference with proper syntax: @Microsoft.KeyVault(SecretUri=https://myvault.vault.azure.net/secrets/myconnectionstring/). Ensure the App Service has 'Key Vault Secrets User' role on the vault.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "在应用设置中使用适用于 Azure SQL 数据库的正确格式：Server=tcp:<server>.database.windows.net,1433;Database=<db>;User ID=<user>@<server>;Password=<password>;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
    "从 Azure 门户获取连接字符串：转到 SQL 数据库 -> 连接字符串 -> ADO.NET，复制确切字符串并粘贴到应用服务的 '连接字符串' 部分，类型选择 'SQLAzure'。",
    "使用正确的语法引用 Key Vault：@Microsoft.KeyVault(SecretUri=https://myvault.vault.azure.net/secrets/myconnectionstring/)。确保应用服务在保管库上具有 'Key Vault Secrets User' 角色。"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://learn.microsoft.com/en-us/azure/app-service/app-service-key-vault-references",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.92,
  "resolvable": "true",
  "first_seen": "2024-03-08",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}