관리되는 노드에 확장 페이로드 설치
적용 대상: Windows 관리 Center, Windows 관리 Center 미리 보기
설치 프로그램
참고 항목
이 가이드를 따르려면 빌드 1.2.1904.02001 이상이 필요합니다. 빌드 번호를 검사 Windows 관리 센터를 열고 오른쪽 위에 있는 물음표를 클릭합니다.
아직 설치하지 않은 경우 Windows 관리 Center용 도구 확장을 만듭니다. 이 작업을 완료한 후에는 확장을 만들 때 사용되는 값을 기록해 둡니다.
값 | 설명 | 예시 |
---|---|---|
{!Company Name} |
회사 이름(공백 포함) | Contoso |
{!Tool Name} |
도구 이름(공백 포함) | InstallOnNode |
도구 확장 폴더 내에 폴더({!Tool Name}\Node
)를 Node
만듭니다. 이 폴더에 배치된 모든 항목은 이 API를 사용할 때 관리되는 노드에 복사됩니다. 사용 사례에 필요한 파일을 추가합니다.
또한 스크립트를 만듭니다 {!Tool Name}\Node\installNode.ps1
. 이 스크립트는 모든 파일이 폴더에서 관리되는 노드로 복사되면 관리되는 노드에서 {!Tool Name}\Node
실행됩니다. 사용 사례에 대한 추가 논리를 추가합니다. 예제 {!Tool Name}\Node\installNode.ps1
파일:
# Add logic for installing payload on managed node
echo 'Success'
참고 항목
{!Tool Name}\Node\installNode.ps1
에는 API가 찾을 특정 이름이 있습니다. 이 파일의 이름을 변경하면 오류가 발생합니다.
UI와 통합
다음으로 업데이트 \src\app\default.component.ts
합니다.
import { Component } from '@angular/core';
import { AppContextService } from '@microsoft/windows-admin-center-sdk/angular';
import { Observable } from 'rxjs';
@Component({
selector: 'default-component',
templateUrl: './default.component.html',
styleUrls: ['./default.component.css']
})
export class DefaultComponent {
constructor(private appContextService: AppContextService) { }
public response: any;
public loading = false;
public installOnNode() {
this.loading = true;
this.post('{!Company Name}.{!Tool Name}', '1.0.0',
this.appContextService.activeConnection.nodeName).subscribe(
(response: any) => {
console.log(response);
this.response = response;
this.loading = false;
},
(error) => {
console.log(error);
this.response = error;
this.loading = false;
}
);
}
public post(id: string, version: string, targetNode: string): Observable<any> {
return this.appContextService.node.post(targetNode,
`features/extensions/${id}/versions/${version}/install`);
}
}
확장을 만들 때 사용된 값으로 자리 표시자를 업데이트합니다.
this.post('contoso.install-on-node', '1.0.0',
this.appContextService.activeConnection.nodeName).subscribe(
(response: any) => {
console.log(response);
this.response = response;
this.loading = false;
},
(error) => {
console.log(error);
this.response = error;
this.loading = false;
}
);
또한 다음으로 업데이트 \src\app\default.component.html
됩니다.
<button (click)="installOnNode()">Click to install</button>
<sme-loading-wheel *ngIf="loading" size="large"></sme-loading-wheel>
<p *ngIf="response">{{response}}</p>
마지막으로 다음을 수행합니다.\src\app\default.module.ts
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { LoadingWheelModule } from '@microsoft/windows-admin-center-sdk/angular';
import { DefaultComponent } from './default.component';
import { Routing } from './default.routing';
@NgModule({
imports: [
CommonModule,
LoadingWheelModule,
Routing
],
declarations: [DefaultComponent]
})
export class DefaultModule { }
NuGet 패키지 만들기 및 설치
마지막 단계는 추가한 파일을 사용하여 NuGet 패키지를 빌드한 다음 Windows 관리 Center에 해당 패키지를 설치하는 것입니다.
이전에 확장 패키지를 만들지 않은 경우 게시 확장 가이드를 따릅니다.
Important
이 확장명용 .nuspec 파일에서 값은 <id>
프로젝트의 manifest.json
이름과 일치하고 추가된 값과 <version>
일치해야 합니다 \src\app\default.component.ts
. 또한 다음 아래에 항목을 추가합니다.<files>
<file src="Node\**\*.*" target="Node" />
.
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="https://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>contoso.install-on-node</id>
<version>1.0.0</version>
<authors>Contoso</authors>
<owners>Contoso</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<projectUrl>https://msft-sme.myget.org/feed/windows-admin-center-feed/package/nuget/contoso.sme.install-on-node-extension</projectUrl>
<licenseUrl>http://YourLicenseLink</licenseUrl>
<iconUrl>http://YourLogoLink</iconUrl>
<description>Install on node extension by Contoso</description>
<copyright>(c) Contoso. All rights reserved.</copyright>
</metadata>
<files>
<file src="bundle\**\*.*" target="ux" />
<file src="package\**\*.*" target="gateway" />
<file src="Node\**\*.*" target="Node" />
</files>
</package>
이 패키지가 만들어지면 해당 피드에 경로를 추가합니다. Windows 관리 센터에서 설정 > 확장 > 피드로 이동하여 해당 패키지가 있는 위치에 대한 경로를 추가합니다. 확장 설치가 완료되면 단추를 클릭 install
할 수 있어야 하며 API가 호출됩니다.