Azure / service-fabric-mesh-preview

Service Fabric Mesh is the Service Fabric's serverless offering to enable developers to deploy containerized applications without managing infrastructure. Service Fabric Mesh , aka project “SeaBreeze” is currently available in private preview. This repository will be used for tracking bugs/feature requests as GitHub issues and for maintaining the latest documentation.
MIT License
82 stars 11 forks source link

az mesh deployment create - yaml template/parameters not working per example in docs #343

Closed displaced closed 5 years ago

displaced commented 5 years ago

Hi,

I'm attempting to use yaml templates and parameter files for my deployment.

I'm following the limited docs available, and have some success when using a set of yaml templates which do not require parameters.

However, if I reference a parameter in the template, then specify the parameter's value in a simple yaml file, the deployment fails, complaining that the template parameter is not found.

My parameters yaml file is very simple -- just parameter_name: "parameter value" -- which the docs suggest is correct - quote:

Create a deployment with yaml files, along with a yaml parameters file, which consists of key/value pairs.

The command-line I'm using is:

az mesh deployment create --resource-group resgroup1 --input-yaml-files ./deploy/common --parameters ./deploy/environments/cloud.yaml

Any advice appreciated.

Chris

anantshankar17 commented 5 years ago

Hello @displaced The parameter yamls, like other yamls should be in the format: key1: value1, key2: value2

displaced commented 5 years ago

Thabks - I tried without the double-quotes and it still didn’t work. Also, I didn’t realise yaml needed commas between pairs - I’ve been doing it wrong for ages!

anantshankar17 commented 5 years ago

yes, actually yamls dont need commas. What I wanted to emphasize was the need for the colon in between the key and values. So ideally the params file should be:

key1: value1 key2: value2

If it still doesnt work, then kindly share all your yamls.

displaced commented 5 years ago

Thanks -- it looks like my yaml syntax is correct. I'll attach them here for verification.

I couldn't find any solid docs on building ARM templates in YAML, so I used those generated by the VS2017 Mesh Toolkit tooling as a starting point (I use vscode for development and would like to deploy via the command-line).

Attached are:

... so additional services would be defined in further svc_*.yaml files.

Lastly, there's cloud.yaml which is meant to contain the parameters for cloud deployment, populating variables within the other yamls.

And just for reference, here's the command-line I'm using once more:

az mesh deployment create --resource-group resgroup1 --input-yaml-files ./deploy/common --parameters ./deploy/environments/cloud.yaml

(I've replaced the appname and registry names with 'example'.)

Thanks for taking the time to look into this for me!

Cheers, Chris

deploy.zip

anantshankar17 commented 5 years ago

Hello @displaced, I dont think the concatenate would work in the way you are trying to do in the parameter value. Instead you can use like this: image: "[parameters('registry_root')]" and then the parameter value becomes: registry_root: exampleregistry.azurecr.io/example/model-engine:latest

displaced commented 5 years ago

Thanks! So would none of the ARM Template Functions be supported when using YAML?

I've now been able to use the parameter substitution as you describe, without using the concat() function -- thanks!

However, I'm now seeing an error in the deployment via the portal. The generated template doesn't seem to be linking the application (app.yml) and the service (svc_modelengine.yaml). The error is:

{
    "id": "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx/resourceGroups/example/providers/Microsoft.Resources/deployments/deployment1/operations/XXXXXXXXXXXXXXXX",
    "operationId": "XXXXXXXXXXXXXXXX",
    "properties": {
        "provisioningOperation": "Create",
        "provisioningState": "Failed",
        "timestamp": "2019-02-04T11:59:39.7460441Z",
        "duration": "PT0.2946017S",
        "trackingId": "b07f6bdc-b5b5-4f2c-8d2c-09f2b4dfeaf6",
        "statusCode": "BadRequest",
        "statusMessage": {
            "error": {
                "code": "BadRequestWithReason",
                "message": "Request is invalid. Reason An application must contain at least one service and code package..",
                "details": [
                    {
                        "code": "Exception",
                        "message": "Microsoft.ServiceFabric.Rp.Errors.WrpException: Request is invalid. Reason An application must contain at least one service and code package..\r\n at Microsoft.SeaBreeze.ApplicationManager.Operation.Applications.ApplicationValidationSeptember2018.<ValidateAsync>d__0.MoveNext() in F:\\aw\\3\\s\\src\\ApplicationManager\\Operation\\Applications\\ApplicationValidationSeptember2018.cs:line 46\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.SeaBreeze.ApplicationManager.Operation.PutApplicationOperation`1.<ExecuteAsync>d__6.MoveNext() in F:\\aw\\3\\s\\src\\ApplicationManager\\Operation\\Applications\\PutApplicationOperation.cs:line 93\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.ServiceFabric.Rp.Operation.OperationBaseWithoutInstrumentation`1.<RunAsync>d__49.MoveNext()"
                    }
                ]
            }
        },
        "targetResource": {
            "id": "/subscriptions/4a3ecbdd-5189-4440-88af-28bd8bfe46cd/resourceGroups/example/providers/Microsoft.ServiceFabricMesh/applications/example",
            "resourceType": "Microsoft.ServiceFabricMesh/applications",
            "resourceName": "example"
        }
    }
}

I've checked my yaml against that which Visual Studio 2017 generates, and I can't see anywhere I've missed some kind of link between the Application and the Service objects!

Thanks again for your help,

Cheers, Chris

jeffj6123 commented 5 years ago

Can you try deploying it without the app.yaml, because that yaml does not have a service within it.

anantshankar17 commented 5 years ago

The issue is that the app.yaml and the service.yaml have different app names:

Service definition

application: schemaVersion: 1.0.0-preview2 name: example

app.yaml

application: schemaVersion: 1.0.0-preview2 name: Grace

displaced commented 5 years ago

Ah - I caught that late last night and fixed it. I left it deploying - I went home after it had been running for maybe an hour or so, which seems a little excessive - but I’ll find out how it’s gone when I get to work this morning.

Thanks for the help!

displaced commented 5 years ago

Right -- it seems that the app is now almost deploying correctly, but I've hit another issue. Feel free to let me know if this needs to go into another issue.

I started from scratch:

Now, the deployment runs, to a point. Gateway and Network are deploying fine. But the application itself is stuck on Created without progressing to OK. The code-package is showing as Waiting in the portal.

The only additional info I've found is via az mesh app show, which gives the following:

 az mesh app show --resource-group testrg1 --name Application3
{
  "debugParams": null,
  "description": "Application3 description.",
  "diagnostics": null,
  "healthState": "Error",
  "id": "/subscriptions/4a3ecbdd-5189-4440-88af-28bd8bfe46cd/resourcegroups/testrg1/providers/Microsoft.ServiceFabricMesh/applications/Application3",
  "location": "westus",
  "name": "Application3",
  "provisioningState": "Updating",
  "resourceGroup": "testrg1",
  "serviceNames": [
    "Web1"
  ],
  "services": null,
  "status": "Upgrading",
  "statusDetails": "Deployment upgrade is in progress. Please check the deployment upgrade status for detailed information.",
  "tags": {},
  "type": "Microsoft.ServiceFabricMesh/applications",
  "unhealthyEvaluation": "Unhealthy deployed applications: 100% (1/1), MaxPercentUnhealthyDeployedApplications=0%.\r\n  Unhealthy deployed application: ApplicationName='fabric:/Application3', NodeName='_Dev_1', AggregatedHealthState='Error'.\r\n    Unhealthy deployed service packages: 100% (1/1).\r\n      Unhealthy deployed service package: ApplicationName='fabric:/Application3', ServiceManifestName='Web1Pkg', ServicePackageActivationId='2717d6a8-dc87-1347-856b-f1be7aaec56c', NodeName='_Dev_1', AggregatedHealthState='Error'.\r\n        Error event: SourceId='System.Hosting', Property='CodePackageActivation:Web1:EntryPoint:131938308898746321'. 'There was an error during CodePackage activation.Service host failed to activate. Error:E_FAIL'\r\n"
} 

Now, the code package is a Docker image. The Dockerfile is:

FROM python:3.6-slim
WORKDIR /app
ADD ./src/ /app
ADD ./requirements.txt /app
RUN pip install -r requirements.txt
EXPOSE 8000
ENTRYPOINT [ "python", "service.py"]

This works fine when deployed to a local Docker instance on my machine. It's pretty basic really, but wonder if I'm missing something here?

Thanks! Chris

displaced commented 5 years ago

Ah -- found it! I noticed that the container registry hadn't logged any pulls for the image. I found how to set the credentials in a JSON template, converted that to YAML and have now deployed successfully.

Thanks!