microsoft / service-fabric-client-dotnet

.NET client library for Service Fabric
MIT License
66 stars 36 forks source link

Unhelpful error when New-SFMeshResourceDeployment fails #71

Closed wasker closed 4 years ago

wasker commented 5 years ago

Describe the bug

I'm trying to troubleshoot ASF Mesh project in VS. When powershell command is executed and something is wrong, the error message is:

2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.SFApp.Sdk\build\Microsoft.VisualStudio.Azure.SFApp.Targets.targets(322,5): error : New-SFMeshResourceDeployment : Input string was not in a correct format. 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.SFApp.Sdk\build\Microsoft.VisualStudio.Azure.SFApp.Targets.targets(322,5): error : At line:1 char:157 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.SFApp.Sdk\build\Microsoft.VisualStudio.Azure.SFApp.Targets.targets(322,5): error : + ... -SFCluster; New-SFMeshResourceDeployment -ResourceDescriptionList 'D: ... 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.SFApp.Sdk\build\Microsoft.VisualStudio.Azure.SFApp.Targets.targets(322,5): error : + ~~~~~~~~~~~~~ 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.SFApp.Sdk\build\Microsoft.VisualStudio.Azure.SFApp.Targets.targets(322,5): error : + CategoryInfo : NotSpecified: (:) [New-SFMeshResourceDeployment], FormatException 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.SFApp.Sdk\build\Microsoft.VisualStudio.Azure.SFApp.Targets.targets(322,5): error : + FullyQualifiedErrorId : DeployMeshResourcesErrorId,Microsoft.ServiceFabric.Powershell.Http.DeployMeshResourcesCmdlet 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.SFApp.Sdk\build\Microsoft.VisualStudio.Azure.SFApp.Targets.targets(322,5): error : 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.SFApp.Sdk\build\Microsoft.VisualStudio.Azure.SFApp.Targets.targets(322,5): error : An error occurred running New-SFMeshResourceDeployment. 2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Sdks\Microsoft.SFApp.Sdk\build\Microsoft.VisualStudio.Azure.SFApp.Targets.targets(322,5): error : Exit Code: 1

To Reproduce

powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "import-module 'C:\Program Files\Microsoft SDKs\Service Fabric\Tools\Mesh\Scripts\PSModule\Microsoft.ServiceFabric.Powershell.Http.psd1'; Connect-SFCluster; New-SFMeshResourceDeployment -ResourceDescriptionList 'D:\work\MyApp\src\App.AsfMesh\App Resources\app.yaml', 'D:\work\MyApp\src\App\Service Resources\service.yaml', 'D:\work\MyApp\src\App.AsfMesh\obj\SFApp\App.debug.yaml', 'D:\work\MyApp\src\App.AsfMesh\App Resources\gateway.yaml', 'D:\work\MyApp\src\App.AsfMesh\App Resources\network.yaml' -ParameterFileName 'D:\work\MyApp\src\App.AsfMesh\Environments\Local\parameters.yaml'"

Expected behavior

If something is wrong with my settings, I expect a helpful error message that explains what is going on.

Additional context Add any other context about the problem here.

wasker commented 5 years ago

The root cause of the problem: mismatch between parameter names used in [parameters('Blah_cpu')] and the ones declared in parameters.yaml.

The error message didn't help me at all.

AaronLS commented 5 years ago

I'm getting this same error but can't find the cause. When you say mismatch, there was not a 'Blah_cpu' parameter declared in YAML? I am going through the SF Mesh tutorial and have double checked all the params, but I am new to YAML. Made sure no tabs, and environment variables lined up. Not sure what else I should look for.

AaronLS commented 5 years ago

If I search solution for "parameters(" these are only results:

port: "[parameters('TodoManagerWebApi_ingressport')]"
port: "[parameters('TodoManagerWeb_ingressport')]"
cpu: "[parameters('TodoManagerWeb_cpu')]"
cpu: "[parameters('TodoManagerWebApi_cpu')]"

In the fabric mesh project, under Environments/Local/parameters.yaml these are defined:

## Parameters file ##
TodoManagerWeb_cpu: 0.5
TodoManagerWeb_ingressport: 8080
TodoManagerWebApi_cpu: 0.5
TodoManagerWebApi_ingressport: 8081

My Web MVC project service.yaml:

## Service definition ##
application:
  schemaVersion: 1.0.0-preview2
  name: TodoManagerFabricMesh
  properties:
    services:
      - name: TodoManagerWeb
        properties:
          description: TodoManagerWeb description.
          osType: Windows
          codePackages:
            - name: TodoManagerWeb
              image: todomanagerweb:dev
              endpoints:
                - name: TodoManagerWebListener
                  port: 8080 
              environmentVariables: 
                - name: ApiHostPort
                  value: 8081
                - name: ToDoServiceName
                  value: TodoManagerWebApi
#               - name: ApplicationInsights:InstrumentationKey
#                 value: "<Place AppInsights key here, or reference it via a secret>"
              resources:
                requests:
                  cpu: "[parameters('TodoManagerWeb_cpu')]"
                  memoryInGB: 1
          replicaCount: 1
          networkRefs:
            - name: TodoManagerFabricMeshNetwork
              endpointRefs:
                - name: TodoManagerWebListener

My Web API service.yaml:

## Service definition ##
application:
  schemaVersion: 1.0.0-preview2
  name: TodoManagerFabricMesh
  properties:
    services:
      - name: TodoManagerWebApi
        properties:
          description: TodoManagerWebApi description.
          osType: Windows
          codePackages:
            - name: TodoManagerWebApi
              image: todomanagerwebapi:dev
              endpoints:
                - name: TodoManagerWebApiListener
                  port: 8081
#              environmentVariables:
#                - name: ApplicationInsights:InstrumentationKey
#                  value: "<Place AppInsights key here, or reference it via a secret>"
              resources:
                requests:
                  cpu: "[parameters('TodoManagerWebApi_cpu')]"
                  memoryInGB: 1
          replicaCount: 1
          networkRefs:
            - name: TodoManagerFabricMeshNetwork
              endpointRefs:
                - name: TodoManagerWebApiListener

Does it matter that the ports don't match up with the ones in the Web MVC project's /Properties/launchSettings.json, it's not really clear to me what service.yaml is doing versus launchSettings.json since both define port numbers for the project. I do understand the env. variables are so the Web project knows where to reach the WebAPI project.

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:52898",
      "sslPort": 0
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    },
    "TodoManager.Web": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "applicationUrl": "http://localhost:5000"
    },
    "Service Fabric Local Cluster": {
      "commandName": "SFApp",
      "launchBrowser": true,
      "launchUrl": "http://{ServiceIpAddress}:{ServicePort}",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      }
    }
  }
}
amanbha commented 4 years ago

Closing SF Mesh related issue