Skip to content

Commit 5184191

Browse files
committed
Update readme
1 parent 96ffc30 commit 5184191

2 files changed

Lines changed: 62 additions & 37 deletions

File tree

README.md

Lines changed: 52 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,78 @@
11
# DSC to Bicep Types Generator
22

3-
This is a work-in-progress app to convert DSC type definitions to Bicep's format.
3+
This is a work-in-progress app to convert DSC type definitions to Bicep's
4+
format, and now includes a DSC gRPC server (written in Rust) to support `bicep
5+
local-deploy`.
46

5-
DSC types are defined inside each resource manifest.
6-
For now, only embedded schemas are supported.
7+
With no arguments, this app will attempt to get the schemas for each available
8+
DSC resource by shelling out to `dsc` (and each resources subcommands if the
9+
manifest isn't embedded, so be sure to have a build of DSC in the `PATH`.
710

8-
Run this app to generate `out/types.json` and `out/index.json`.
9-
Then run `bicep publish-extension --target out/dsc.tgz out/index.json`.
10-
Move this file to wherever you'll refer to it in Bicep's configuration.
11+
The app will then run `bicep publish-extension ... --target out/dsc.tgz` where
12+
the rest of the arguments are the generated types (in the `out` directory) and
13+
the `dscbicep` binary, which currently only exists in DSC's `biecp-gRPC` branch.
14+
15+
That emitted tarball is an OCI artifact recognized by Bicep as an extension,
16+
which we then need to configure. Note that that the only experimental feature of
17+
Bicep we're using now is [Local Deploy][]. The extension contains the generated
18+
type definitions and `dscbicep`, which is a small gRPC server that handles
19+
requests from `bicep local-deploy` by calling into `dsc-lib`. At no point are we
20+
passing JSON files to DSC, or calling the `dsc` CLI. Using Local Deploy, Bicep
21+
_remains_ the orchestrator of Bicep code, meaning that everything just works.
22+
The gRPC server is implemented in in [PR #1330][].
23+
24+
On Windows, Rust doesn't really support Unix Domain Sockets so Bicep needed to
25+
be patched to prefer Named Pipes. Until [PR #18712][] is merged and a new release is
26+
out, a developer build of that will be needed too. This does not apply to macOS.
27+
28+
[local deploy]: https://github.com/Azure/bicep/blob/main/docs/experimental/local-deploy.md
29+
[PR #1330]: https://github.com/PowerShell/DSC/pull/1330
30+
[PR #18712]: https://github.com/Azure/bicep/pull/18712
1131

1232
In `bicepconfig.json` enable extensibility and add the extension:
1333

1434
```json
1535
{
1636
"experimentalFeaturesEnabled": {
17-
"desiredStateConfiguration": true
37+
"localDeploy": true
1838
},
1939
"extensions": {
20-
"dsc": "./dsc.tgz"
40+
"dsc": "./out/dsc.tgz"
2141
},
2242
"implicitExtensions": []
2343
}
2444
```
2545

26-
Then at the top of your Bicep file, enable both the extension and the target scope:
46+
Then at the top of your Bicep file, enable both the extension and the _local_ target scope:
2747

2848
```bicep
2949
extension dsc
30-
targetScope = 'desiredStateConfiguration'
50+
targetScope = 'local'
3151
```
3252

33-
Now you'll have resource completions for DSC.
34-
However, it won't work yet. Two issues to solve:
53+
See `example.bicep`, `macos.bicep`, `windows.bicep` and their associated
54+
`.bicepparam` files for more detailed examples.
3555

36-
1. Enabling these Bicep configs moves to ARMv2 which emits resources as a dict instead of an array.
37-
2. A new 'imports' property (with our extension) is emmited.
38-
39-
We actually don't have to use the version,
40-
but the Bicep extension likes to auto-complete type with `@`.
56+
Use the `Local Deploy` VS Code task to launch one of the examples. It's
57+
equivalent to: `bicep local-deploy example.bicepparam`, but patches the path to
58+
the dev build of Bicep and has some environment variables you can edit for
59+
debugging.
4160

4261
## Building
4362

44-
1. Install [Node.js](https://nodejs.org/en/download)
45-
2. Clone repo: `git clone https://github.com/microsoft/bicep-types-dsc.git`
46-
3. Clone submodules: `git submodule update --init`
47-
4. Build `bicep-types`:
48-
1. `cd bicep-types/src/bicep-types`
49-
2. `npm install`
50-
3. `npm run build`
51-
4. `cd ../../..`
52-
5. `npm install`
53-
6. With `dsc` and `bicep` in `PATH`:
54-
1. Run `npm start`
63+
1. Install [Node.js](https://nodejs.org/en/download), for this extension
64+
2. Install [Rust](https://rust-lang.org/tools/install/), for DSC
65+
3. Install [.NET SDK](https://dotnet.microsoft.com/en-us/download), for Bicep
66+
4. Clone this repo: `git clone https://github.com/microsoft/bicep-types-dsc.git`
67+
5. Clone DSC feature branch: `git clone -b bicep-gRPC https://github.com/andyleejordan/DSC.git`
68+
6. Clone Bicep feature branch: `git clone -b named-pipes https://github.com/andyleejordan/bicep.git`
69+
7. Open this project's multi-root workspace: `code bicep-types-dsc/bicep-types-dsc.code-workspace`
70+
8. Run `Publish Extension` VS Code workspace build task, equivalent to:
71+
- `cd dsc && ./build.ps1 -Project dscbicep`
72+
- `cd bicep-types-dsc && npm start` (might need `npm install` first)
73+
9. Run `Build CLI` VS Code Bicep task, equivalent to:
74+
- `cd bicep && dotnet build src/Bicep.Cli/Bicep.Cli.csproj`
75+
76+
DSC sometimes needs the CFS Cargo feed updated. A Microsoft employee can add
77+
`-UseCFS` to the build command. This project sometimes needs the CFS NPM feed
78+
updated. A Microsoft employee can follow a GUI-driven login procedure.

bicep-types-dsc.code-workspace

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,29 +84,30 @@
8484
"BICEP_TRACING_ENABLED": "false",
8585
"BICEP_TRACING_VERBOSITY": "basic",
8686
"DSC_TRACE_LEVEL": "TRACE",
87-
"DSC_GRPC_DEBUG": "false",
87+
"DSC_GRPC_DEBUG": "false"
8888
}
8989
},
9090
"windows": {
9191
"options": {
9292
"env": {
9393
"DSC_RESOURCE_PATH": "${workspaceFolder:DSC}\\bin\\debug;${env:PATH}",
9494
"PATH": "${workspaceFolder:DSC}\\bin\\debug;${env:PATH}"
95-
},
95+
}
9696
}
9797
},
9898
"osx": {
9999
"options": {
100100
"env": {
101101
"DSC_RESOURCE_PATH": "${workspaceFolder:DSC}/bin/debug:${env:PATH}",
102102
"PATH": "${workspaceFolder:DSC}/bin/debug:${env:PATH}"
103-
},
103+
}
104104
}
105105
},
106106
"presentation": {
107107
"reveal": "always"
108108
},
109-
"group": "test"
109+
"group": "test",
110+
"problemMatcher": []
110111
},
111112
{
112113
"label": "Launch gRPC UI",
@@ -130,8 +131,8 @@
130131
"args": [
131132
"-NoProfile",
132133
"-Command"
133-
],
134-
},
134+
]
135+
}
135136
},
136137
"presentation": {
137138
"reveal": "always"
@@ -147,20 +148,20 @@
147148
"type": "shell",
148149
"command": "npm run start",
149150
"options": {
150-
"cwd": "${workspaceFolder:bicep-types-dsc}",
151+
"cwd": "${workspaceFolder:bicep-types-dsc}"
151152
},
152153
"windows": {
153154
"options": {
154155
"env": {
155156
"PATH": "${workspaceFolder:DSC}\\bin\\debug;${env:PATH}"
156-
},
157+
}
157158
}
158159
},
159160
"osx": {
160161
"options": {
161162
"env": {
162163
"PATH": "${workspaceFolder:DSC}/bin/debug:${env:PATH}"
163-
},
164+
}
164165
}
165166
},
166167
"dependsOn": [

0 commit comments

Comments
 (0)