Skip to content

Commit

Permalink
Add environment variables to ContainerApps task
Browse files Browse the repository at this point in the history
  • Loading branch information
Basssiiie committed Jan 11, 2023
1 parent 39de17a commit 53e8d41
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions Tasks/AzureContainerAppsV0/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ Below are the arguments that can be provided to this task.
| `containerAppEnvironment` | No | The name of the Container App environment to use with the application. If not provided, an existing environment in the resource group of the Container App will be used, otherwise, an environment will be created in the formation `<container-app-name>-env`. |
| `runtimeStack` | No | The platform version stack used in the final runnable application image that is deployed to the Container App. The value should be provided in the formation `<platform>:<version>`. If not provided, this value is determined by Oryx based on the contents of the provided application. Please refer to [this document](https://github.com/microsoft/Oryx/blob/main/doc/supportedRuntimeVersions.md) for more information on supported runtime stacks for Oryx. |
| `targetPort` | No | The target port that the Container App will listen on. If not provided, this value will be "80" for Python applications and "8080" for all other supported platforms. |
| `environmentVariables` | No | A list of environment variable(s) for the container. Space-separated values in 'key=value' format. Empty string to clear existing values. Prefix value with 'secretref:' to reference a secret. |

## Usage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"loc.input.help.runtimeStack": "The platform version stack that the application runs in when deployed to the Azure Container App. This should be provided in the form of <platform>:<version>. If not provided, this value is determined by Oryx based on the contents of the provided application. Please view the following document for more information on the supported runtime stacks for Oryx: https://github.com/microsoft/Oryx/blob/main/doc/supportedRuntimeVersions.md",
"loc.input.label.targetPort": "Application target port",
"loc.input.help.targetPort": "The designated port for the application to run on. If not provided, this value is 80 for Python applications, and 8080 for all other supposed platforms.",
"loc.input.label.environmentVariables": "Environment variables",
"loc.input.help.environmentVariables": "A list of environment variable(s) for the container. Space-separated values in 'key=value' format. Empty string to clear existing values. Prefix value with 'secretref:' to reference a secret.",
"loc.messages.AcrAccessTokenAuthFailed": "Unable to authenticate against ACR instance '%s.azurecr.io' with access token.",
"loc.messages.AcrAccessTokenLoginMessage": "Logging in to Azure Container Registry using access token to be generated via Azure CLI.",
"loc.messages.AcrUsernamePasswordAuthFailed": "Unable to authenticate against ACR instance '%s.azurecr.io' with username/password.",
Expand Down
7 changes: 7 additions & 0 deletions Tasks/AzureContainerAppsV0/azurecontainerapps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,13 @@ export class azurecontainerapps {
if (!!targetPort) {
optionalCmdArgs.push(`--target-port ${targetPort}`);
}

// Add user specified environment variables
const environmentVariables: string = tl.getInput('environmentVariables', false);
if (!!environmentVariables) {
console.log(tl.loc('DefaultEnvironmentVariablesMessage', environmentVariables));
optionalCmdArgs.push(`--env-vars ${environmentVariables}`);
}

// If using the Oryx++ Builder to produce an image, create a runnable application image
if (!dockerfilePath && shouldBuildAndPushImage) {
Expand Down
9 changes: 8 additions & 1 deletion Tasks/AzureContainerAppsV0/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"version": {
"Major": 0,
"Minor": 215,
"Minor": 217,
"Patch": 0
},
"preview": true,
Expand Down Expand Up @@ -134,6 +134,13 @@
"label": "Application target port",
"required": false,
"helpMarkDown": "The designated port for the application to run on. If not provided, this value is 80 for Python applications, and 8080 for all other supposed platforms."
},
{
"name": "environmentVariables",
"type": "string",
"label": "Environment variables",
"required": false,
"helpMarkDown": "A list of environment variable(s) for the container. Space-separated values in 'key=value' format. Empty string to clear existing values. Prefix value with 'secretref:' to reference a secret."
}
],
"execution": {
Expand Down
9 changes: 8 additions & 1 deletion Tasks/AzureContainerAppsV0/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"version": {
"Major": 0,
"Minor": 215,
"Minor": 217,
"Patch": 0
},
"preview": true,
Expand Down Expand Up @@ -134,6 +134,13 @@
"label": "ms-resource:loc.input.label.targetPort",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.targetPort"
},
{
"name": "environmentVariables",
"type": "string",
"label": "ms-resource:loc.input.label.environmentVariables",
"required": false,
"helpMarkDown": "ms-resource:loc.input.help.environmentVariables"
}
],
"execution": {
Expand Down

0 comments on commit 53e8d41

Please sign in to comment.