base64

概要

入力文字列の base64 表現を返します。

構文

base64(<inputString>)

説明

関数は base64() 、入力文字列の base64 表現を返します。 base64 としてエンコードされたデータを渡すと、特に異なるツールで異なるエスケープ文字が必要な場合に、データを渡す際のエラーを減らすことができます。

例 1 - 文字列を base64 に変換する

この構成では、 関数を使用して基本的な文字列値を base64() 変換します。

# base64.example.1.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
  - name: Echo 'abc' in base64
    type: Microsoft.DSC.Debug/Echo
    properties:
      output: "[base64('abc')]"
dsc --file base64.example.1.dsc.config.yaml config get
results:
- name: Echo 'abc' in base64
  type: Microsoft.DSC.Debug/Echo
  result:
    actualState:
      output: YWJj
messages: []
hadErrors: false

例 2 - 連結された文字列を base64 に変換する

この構成では、base64 表現を返す前に、関数内の base64()concat() 関数を使用して、文字列 ab、および cabc を 結合します。

# base64.example.2.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
  - name: Echo concatenated 'a', 'b', 'c' in base64
    type: Microsoft.DSC.Debug/Echo
    properties:
      output: "[base64(concat('a', 'b', 'c'))]"
dsc --file base64.example.2.dsc.config.yaml config get
results:
- name: Echo concatenated 'a', 'b', 'c' in base64
  type: Microsoft.DSC.Debug/Echo
  result:
    actualState:
      output: YWJj
messages: []
hadErrors: false

パラメーター

inputString

関数では base64() 、入力として 1 つの文字列が必要です。 関数は、値を base64 表現に変換します。 値が文字列でない場合、構成ドキュメントを検証するときに DSC によってエラーが発生します。

Type:         string
Required:     true
MinimumCount: 1
MaximumCount: 1

出力

関数はbase64()、inputString 値の base64 表現を返します。

Type: string