You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/deployment-environments/how-to-configure-extensibility-model-custom-image.md
+148-1Lines changed: 148 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,7 +79,7 @@ After you complete the image customization, you can build the image and push it
79
79
80
80
Rather than building your custom image and pushing it to a container registry yourself, you can use a script to build and push it to a specified container registry.
### [Use a standard container image](#tab/standard/)
242
+
243
+
### Use a standard container image provided by Pulumi
244
+
245
+
The Pulumi team provides a prebuilt image to get you started, which you can see in the [Runner-Image](https://github.com/pulumi/azure-deployment-environments/tree/main/Runner-Image) folder. This image is publicly available at Pulumi's Docker Hub as [`pulumi/azure-deployment-environments`](https://hub.docker.com/repository/docker/pulumi/azure-deployment-environments), so you can use it directly from your ADE environment definitions.
246
+
247
+
Here's a sample *environment.yaml* file that utilizes the prebuilt image:
248
+
249
+
```yaml
250
+
name: SampleDefinition
251
+
version: 1.0.0
252
+
summary: First Pulumi-Enabled Environment
253
+
description: Deploys a Storage Account with Pulumi
You can find a few sample environment definitions in the [Environments folder](https://github.com/pulumi/azure-deployment-environments/tree/main/Environments).
259
+
260
+
### [Create a custom image](#tab/custom/)
261
+
262
+
### Create a custom image
263
+
264
+
Creating a custom container image allows you to customize your deployments to fit your requirements. You can create custom images based on the Pulumi standard images, and customize them to meet your requirements. After you complete the image customization, you must build the image and push it to your container registry.
265
+
266
+
To create an image configured for ADE, follow these steps:
267
+
1. Create a custom image based on a standard image.
268
+
1. Install desired packages.
269
+
1. Configure operation shell scripts.
270
+
1. Create operation shell scripts that use the Pulumi CLI.
271
+
272
+
**1. Create a custom image based on a standard image**
273
+
274
+
Create a DockerFile that includes a FROM statement pointing to a standard image hosted on Microsoft Artifact Registry.
275
+
276
+
Here's an example FROM statement, referencing the standard core image:
277
+
278
+
```docker
279
+
FROM mcr.microsoft.com/deployment-environments/runners/core:latest
280
+
```
281
+
282
+
This statement pulls the most recently published core image, and makes it a basis for your custom image.
283
+
284
+
**2. Install required packages**
285
+
286
+
You can install the Pulumi CLI to an executable location so that it can be used in your deployment and deletion scripts.
287
+
288
+
Here's an example of that process, installing the latest version of the Pulumi CLI:
289
+
290
+
```docker
291
+
RUN apk add curl
292
+
RUN curl -fsSL https://get.pulumi.com | sh
293
+
ENV PATH="${PATH}:/root/.pulumi/bin"
294
+
```
295
+
296
+
Depending on which programming language you intend to use for Pulumi programs, you might need to install one or more corresponding runtimes. The Python runtime is already available in the base image.
297
+
298
+
Here's an example of installing Node.js and TypeScript:
299
+
300
+
```docker
301
+
# install node.js, npm, and typescript
302
+
RUN apk add nodejs npm
303
+
RUN npm install typescript -g
304
+
```
305
+
306
+
The ADE standard images are based on the Azure CLI image, and have the ADE CLI and JQ packages preinstalled. You can learn more about the [Azure CLI](/cli/azure/), and the [JQ package](https://devdocs.io/jq/).
307
+
308
+
To install any more packages you need within your image, use the RUN statement.
309
+
310
+
There are four steps to deploy infrastructure via Pulumi:
311
+
312
+
1.`pulumi login` - connect to the state storage, either in local file system or in [Pulumi Cloud](https://www.pulumi.com/product/pulumi-cloud/)
313
+
1.`pulumi stack select` - create or select the stack to use for the particular environment
1.`pulumi up` - run the deployment to create new or update existing infrastructure in Azure
316
+
317
+
During the core image's entrypoint, any existing local state files are pulled into the container and the directory saved under the environment variable ```$ADE_STORAGE```. In order to access the existing state file, run the following commands:
318
+
319
+
```bash
320
+
mkdir -p $ADE_STORAGE
321
+
export PULUMI_CONFIG_PASSPHRASE=
322
+
pulumi login file://$ADE_STORAGE
323
+
```
324
+
325
+
To sign in to Pulumi Cloud instead, set your Pulumi access token as an environment variable, and run the following commands:
Any parameters set for the current environment are stored under the variable ```$ADE_OPERATION_PARAMETERS```. Additionally, the selected Azure region and resource group name are passed in ```ADE_ENVIRONMENT_LOCATION``` and ```ADE_RESOURCE_GROUP_NAME``` respectively. In order to set your Pulumi stack config, run the following commands:
333
+
334
+
```bash
335
+
# Create or select the stack for the current environment
Additionally, to utilize ADE privileges to deploy infrastructure inside your subscription, your script needs to use ADE Managed Service Identity (MSI) when provisioning infrastructure by using the Pulumi Azure Native or Azure Classic provider. If your deployment needs special permissions to complete your deployment, such as particular roles, assign those permissions to the project environment type's identity that is being used for your environment deployment. ADE sets the relevant environment variables, such as the client, tenant, and subscription IDs within the core image's entrypoint, so run the following commands to ensure the provider uses ADE MSI:
351
+
352
+
```bash
353
+
export ARM_USE_MSI=true
354
+
export ARM_CLIENT_ID=$ADE_CLIENT_ID
355
+
export ARM_TENANT_ID=$ADE_TENANT_ID
356
+
export ARM_SUBSCRIPTION_ID=$ADE_SUBSCRIPTION_ID
357
+
```
358
+
359
+
Now, you can run the `pulumi up`command to execute the deployment:
360
+
```bash
361
+
pulumi up --refresh --yes --config-file $PULUMI_CONFIG_FILE
362
+
```
363
+
364
+
During your deletion script, you can instead run the `destroy` command, as shown in the following example:
Finally, to make the outputs of your deployment uploaded and accessible when accessing your environment via the Azure CLI, transform the output object from Pulumi to the ADE-specified format through the JQ package. Set the value to the $ADE_OUTPUTS environment variable, as shown in the following example:
0 commit comments