Edit

Share via


Quickstart: Create a basic solution with common configurations

In this quickstart, you create a basic solution with common configurations using the workload orchestration via CLI. The solution is a Helm chart that contains the application and its dependencies. The common configurations are used to define the configurable attributes at each hierarchical level that can be used for a particular solution.

Prerequisites

Note

You can reuse the global variables defined in Prepare the basics to run workload orchestration and the resource variables defined in Set up the resources of workload orchestration.

Define the variables for solution templating

Create the template and schema files by referring to common-config.yaml, common-schema.yaml and app-config-template.yaml in the compressed folder from the GitHub repository.

# Create variables for schema
# Enter schema name
schemaName="Common schema"
# Enter schema file name
schemaFile="common-schema.yaml"
# Enter schema version in x.x.x format
schemaVersion="1.0.0"
# Enter name for common config
configName="common-config"
# Enter config file name
configFile="common-config.yaml"
# Enter config version name
configVersion="1.0.0"

# Create variables for application/solution
# Change version number if you have tried multiple times

# Edit "app-config-template.yaml" & add these 2 new configs. Change names in $config lookup as per your resources.
#  SqlServerEndpoint: ${{$config(CommonConfig/version1,SqlServerEndpoint)}}
#  LineHealthEndpoint: ${{$config(CommonConfig/version1,LineHealthEndpoint)}}

# Enter name of application
appName1="PriceDetector"
# Enter value in x.x.x format
appVersion="1.0.2"
# Enter description for application
desc="To calculate total by detecting price of each item"
# Enter capabilities of application
appCapList1="[soap,conditioner]"
# Enter configuration template file name for the application 
appConfig="app-config-template.yaml"

Create the solution template

The solution template consists of a schema and a configuration template. Both are defined in YAML format.

Create a common schema

In this quickstart you use a common schema. Common schemas define configurable attributes at each hierarchical level that can be used for a particular solution.

  1. Create the common solution schema. The following command takes version input from CLI argument:

    # Create Shared Solution Schema
    az workload-orchestration schema create --resource-group "$rg" --location "$l" --schema-name "$schemaName" --version "$schemaVersion" --schema-file "$schemaFile"
    
    # View Schema
    az workload-orchestration schema version show --resource-group "$rg" --schema-name "$schemaName" --version "$schemaVersion"
    
  2. You can provide version on file instead of as a CLI argument. Add below section to the shared-schema.yaml file.

    metadata:
        name: <name> [optional]
        version: <version> [optional]
    
  3. Run the same CLI command without --version argument. The service takes version input from file.

    # Create Shared Solution Schema
    az workload-orchestration schema create --resource-group "$rg" --location "$l" --schema-name "$schemaName" --schema-file "$schemaFile"
    

The name field is introduced for user to identify the resource name and its version the file refers to. If name is provided, then it should match --schema-name argument.

Create the configuration

Create the configuration template. The following command takes version input from CLI argument:

az workload-orchestration config-template create --resource-group "$rg" --location "$l" --config-template-name "$configName" --version "$configVersion" --configuration-template-file "$configFile" --description "<description>"

Create the solution

  1. Create a specs.json file by referring to specs.json in the compressed folder from the GitHub repository.

  2. In your specs.json file, update the helm url, for example, contosocm.azurecr.io/helm/app, and chart version in x.x.x format, for example, 0.5.0. Update the app-config-template.yaml file with proper reference to your schema which you created in the above step.

  3. Create the Helm solution. The following command takes version input from CLI argument:

    az workload-orchestration solution-template create --resource-group "$rg" --location "$l" --solution-template-name "$appName1" --description "$desc" --capabilities "$appCapList1" --config-template-file "$appConfig" --specification "@specs.json" --version "$appVersion"
    

    Version can be provided on file instead of as a CLI argument. Add the following section to the app-config-template.yaml file:

    metadata:
        name: <name> [optional]
        version: <version> [optional]
    

    Run the same CLI command without the --version argument. The service will take the version input from the file.

    az workload-orchestration solution-template create --resource-group "$rg" --location "$l" --solution-template-name "$appName1" --description "$desc" --capabilities "$appCapList1" --config-template-file "$appConfig" --specification "@specs.json"
    

Set the configuration values for the solution

  1. View parameters at the parent level, for example, Contoso factory:

    az workload-orchestration configuration show --resource-group "$rg" --target-name "$parentName" --solution-template-name "$appName1"
    
  2. Edit parameters at the parent level:

    az workload-orchestration configuration set --resource-group "$rg" --target-name "$parentName" --solution-template-name "$appName1"
    
  3. View parameters at the child level:

    az workload-orchestration configuration show --resource-group "$rg" --target-name "$childName" --solution-template-name "$appName1"
    
  4. Edit parameters at the child level:

    az workload-orchestration configuration set --resource-group "$rg" --target-name "$childName" --solution-template-name "$appName1"
    

Tip

You can also set the configuration values for the solution using the Configure tab in Workload orchestration portal

Deploy the solution

  1. Review the configurations for a particular target. In the CLI output, check reviewId and name. The name displays the new solution template version.

    az workload-orchestration target review --resource-group "$rg" --target-name "$childName" --solution-template-version-id "/subscriptions/$subId/resourceGroups/$rg/providers/Microsoft.Edge/solutionTemplates/$appName1/versions/$appVersion"
    
  2. Publish the generated configuration for deployment. Enter reviewId from the previous command response.

    reviewId="<reviewId>"
    az workload-orchestration target publish --resource-group "$rg" --target-name "$childName" --solution-version-id /subscriptions/$subId/resourceGroups/$rg/providers/Microsoft.Edge/targets/$childName/solutions/$appName1/versions/$appVersion
    
  3. Deploy the solution.

    az workload-orchestration target install --resource-group "$rg" --target-name "$childName" --solution-version-id /subscriptions/$subId/resourceGroups/$rg/providers/Microsoft.Edge/targets/$childName/solutions/$appName1/versions/$appVersion
    
  4. In case of multiple versions of a solution deployed, you can list all instances or revisions of a solution deployed on a target.

    # List all instances
    az workload-orchestration target solution-instance-list -g "$rg" --target-name "$childName" --solution "$appName1"
    
    # List all revisions
    az workload-orchestration target solution-revision-list -g "$rg" --target-name "$childName" --solution "$appName1"
    

Tip

You can also deploy the solution using the Deploy tab in Workload orchestration portal