升级Service Fabric SDK至2.8/3.0后,VSTS部署Compose应用至SF失败
I ran into this exact issue when upgrading from SDK 2.7 to 3.0 a while back—turns out the problem comes from stricter validation rules for service DNS names introduced in Service Fabric SDK 2.8 and later versions. Here's how to resolve it:
Why this error pops up
Before SDK 2.8, Service Fabric was pretty lenient with what counted as a valid service DNS name. Starting with 2.8, however, DNS names must strictly follow RFC 1123 standards, which enforces these rules:
- Only lowercase letters, numbers, and hyphens (
-) are allowed - Cannot start or end with a hyphen
- Maximum length of 63 characters
Step-by-step fixes
Audit your docker-compose.yml service names
Open yourdocker-compose.ymlfile and check each service's name. If any name uses uppercase letters, underscores (_), dots (.), or starts/ends with a hyphen, adjust it to fit the rules. Examples:- Bad:
My_Service-123→ Good:my-service-123 - Bad:
-MyService→ Good:myservice - Bad:
service.name→ Good:service-name
- Bad:
Check manual DNS name configurations
If you explicitly set aServiceDnsNameparameter in your VSTS "Deploy Compose Application to Service Fabric" task or in your Service Fabric application manifest, double-check that this value adheres to the RFC 1123 rules. Even a single uppercase letter will trigger the error now.Validate names with Service Fabric tools
To confirm your adjusted DNS name is valid, use the built-in PowerShell cmdlet from the Service Fabric SDK:Test-ServiceFabricServiceDnsName -ServiceDnsName "your-adjusted-dns-name"A return value of
Truemeans your name is compliant; if it'sFalse, keep tweaking until it passes.Redeploy your application
After fixing all invalid DNS names, rerun your VSTS deployment task. The error should disappear once all names meet the new validation standards.
内容的提问来源于stack exchange,提问作者Kai Walter

