Skip to content

Commit aab4d52

Browse files
committed
Add debug
1 parent e06108d commit aab4d52

File tree

3 files changed

+83
-25
lines changed

3 files changed

+83
-25
lines changed

action.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
name: 'Create Azure ML Online Endpoint'
2-
description: 'Create an Azure ML Online Endpoint'
1+
name: 'Create Azure Machine Learning Online Endpoint'
2+
description: 'Create an Azure Machine Learning Online Endpoint'
33
author: 'Marc van Duyn'
44
branding:
55
icon: 'cloud'

dist/index.js

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,63 +15,87 @@ __nccwpck_require__.r(__webpack_exports__);
1515

1616

1717
async function checkIfEndpointExists(endpointName, resourceGroup, workspaceName) {
18+
let errorOutput = "";
19+
let output = "";
20+
1821
try {
19-
let output = "";
2022
const options = {
2123
listeners: {
2224
stdout: (data) => {
2325
output += data.toString();
26+
},
27+
stderr: (data) => {
28+
errorOutput += data.toString();
2429
}
2530
},
2631
silent: true
2732
};
2833

2934
// Check if the endpoint exists
30-
await exec.exec(`az ml online-endpoint show --name ${endpointName} --resource-group ${resourceGroup} --workspace-name ${workspaceName}`, [], options);
35+
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec(`az ml online-endpoint show --name ${endpointName} --resource-group ${resourceGroup} --workspace-name ${workspaceName}`, [], options);
3136

37+
console.log("✅ Endpoint already exists. Output:", output);
3238
return true; // If the command succeeds, the endpoint exists
3339
} catch (error) {
3440
return false; // If the command fails, the endpoint does not exist
3541
}
3642
}
3743

3844
async function checkIfResourceGroupExists(resourceGroup) {
45+
let errorOutput = "";
46+
let output = "";
47+
3948
try {
40-
let output = "";
4149
const options = {
4250
listeners: {
4351
stdout: (data) => {
4452
output += data.toString();
53+
},
54+
stderr: (data) => {
55+
errorOutput += data.toString();
4556
}
4657
},
4758
silent: true
4859
};
60+
// Execute the Azure CLI command
61+
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec(`az group show --name ${resourceGroup} --resource-group ${resourceGroup}`, [], options);
4962

50-
// Check if the resource group exists
51-
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec(`az group show --name ${resourceGroup}`, [], options);
52-
return true; // If the command succeeds, the endpoint exists
63+
console.log("✅ Resource Group Found. Output:", output);
64+
return true;
5365
} catch (error) {
54-
return false; // If the command fails, the endpoint does not exist
66+
console.log(
67+
"❌ Resource Group Not Found or Error Occurred:", errorOutput || error.message
68+
);
69+
return false; // Return false if the workspace does not exist
5570
}
5671
}
5772

5873
async function checkIfWorkspaceExists(workspaceName, resourceGroup) {
74+
let errorOutput = "";
75+
let output = "";
76+
5977
try {
60-
let output = "";
6178
const options = {
6279
listeners: {
6380
stdout: (data) => {
6481
output += data.toString();
82+
},
83+
stderr: (data) => {
84+
errorOutput += data.toString();
6585
}
6686
},
6787
silent: true
6888
};
6989

7090
// Check if the workspace exists
7191
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec(`az ml workspace show --name ${workspaceName} --resource-group ${resourceGroup}`, [], options);
72-
return true; // If the command succeeds, the endpoint exists
92+
console.log("✅ Resource Group Found. Output:", output);
93+
return true;
7394
} catch (error) {
74-
return false; // If the command fails, the endpoint does not exist
95+
console.log(
96+
"❌ Resource Group Not Found or Error Occurred:", errorOutput || error.message
97+
);
98+
return false;
7599
}
76100
}
77101

@@ -97,8 +121,11 @@ try {
97121
console.log(`🔹 Checking if resource group '${resourceGroup}' exists...`)
98122
;
99123
const resourceGroupExists = await checkIfResourceGroupExists(resourceGroup);
124+
100125
if (!resourceGroupExists) {
101126
throw new Error(`Resource group '${resourceGroup}' does not exist.`);
127+
} else {
128+
console.log(`✅ Resource group '${resourceGroup}' exists.`);
102129
}
103130

104131
// Check if the workspace exists
@@ -108,17 +135,19 @@ try {
108135

109136
if (!workspaceExists) {
110137
throw new Error(`Workspace '${workspaceName}' does not exist in resource group '${resourceGroup}'.`);
138+
} else {
139+
console.log(`✅ Workspace '${workspaceName}' exists in resource group '${resourceGroup}'.`);
111140
}
112141

113142
console.log(`🔹 Checking if endpoint '${endpointName}' exists...`);
114-
const exists = await endpointExists(
143+
const exists = await checkIfEndpointExists(
115144
endpointName, resourceGroup, workspaceName
116145
);
117146

118147
if (exists) {
119148
console.log(`✅ Endpoint '${endpointName}' already exists. Skipping creation.`);
120149
} else {
121-
console.log(`🔹 Creating endpoint '${endpointName}'...`);
150+
console.log(`🔹 Endpoint does not exist, creating it ...`)
122151
await _actions_exec__WEBPACK_IMPORTED_MODULE_1__.exec(`az ml online-endpoint create --name ${endpointName} --resource-group ${resourceGroup} --workspace-name ${workspaceName}`);
123152
console.log(`✅ Successfully created endpoint: ${endpointName}`);
124153
}

index.js

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ import * as core from "@actions/core";
22
import * as exec from "@actions/exec";
33

44
async function checkIfEndpointExists(endpointName, resourceGroup, workspaceName) {
5+
let errorOutput = "";
6+
let output = "";
7+
58
try {
6-
let output = "";
79
const options = {
810
listeners: {
911
stdout: (data) => {
1012
output += data.toString();
13+
},
14+
stderr: (data) => {
15+
errorOutput += data.toString();
1116
}
1217
},
1318
silent: true
@@ -16,49 +21,68 @@ async function checkIfEndpointExists(endpointName, resourceGroup, workspaceName)
1621
// Check if the endpoint exists
1722
await exec.exec(`az ml online-endpoint show --name ${endpointName} --resource-group ${resourceGroup} --workspace-name ${workspaceName}`, [], options);
1823

24+
console.log("✅ Endpoint already exists. Output:", output);
1925
return true; // If the command succeeds, the endpoint exists
2026
} catch (error) {
2127
return false; // If the command fails, the endpoint does not exist
2228
}
2329
}
2430

2531
async function checkIfResourceGroupExists(resourceGroup) {
32+
let errorOutput = "";
33+
let output = "";
34+
2635
try {
27-
let output = "";
2836
const options = {
2937
listeners: {
3038
stdout: (data) => {
3139
output += data.toString();
40+
},
41+
stderr: (data) => {
42+
errorOutput += data.toString();
3243
}
3344
},
3445
silent: true
3546
};
47+
// Execute the Azure CLI command
48+
await exec.exec(`az group show --name ${resourceGroup} --resource-group ${resourceGroup}`, [], options);
3649

37-
// Check if the resource group exists
38-
await exec.exec(`az group show --name ${resourceGroup}`, [], options);
39-
return true; // If the command succeeds, the endpoint exists
50+
console.log("✅ Resource Group Found. Output:", output);
51+
return true;
4052
} catch (error) {
41-
return false; // If the command fails, the endpoint does not exist
53+
console.log(
54+
"❌ Resource Group Not Found or Error Occurred:", errorOutput || error.message
55+
);
56+
return false; // Return false if the workspace does not exist
4257
}
4358
}
4459

4560
async function checkIfWorkspaceExists(workspaceName, resourceGroup) {
61+
let errorOutput = "";
62+
let output = "";
63+
4664
try {
47-
let output = "";
4865
const options = {
4966
listeners: {
5067
stdout: (data) => {
5168
output += data.toString();
69+
},
70+
stderr: (data) => {
71+
errorOutput += data.toString();
5272
}
5373
},
5474
silent: true
5575
};
5676

5777
// Check if the workspace exists
5878
await exec.exec(`az ml workspace show --name ${workspaceName} --resource-group ${resourceGroup}`, [], options);
59-
return true; // If the command succeeds, the endpoint exists
79+
console.log("✅ Resource Group Found. Output:", output);
80+
return true;
6081
} catch (error) {
61-
return false; // If the command fails, the endpoint does not exist
82+
console.log(
83+
"❌ Resource Group Not Found or Error Occurred:", errorOutput || error.message
84+
);
85+
return false;
6286
}
6387
}
6488

@@ -84,8 +108,11 @@ try {
84108
console.log(`🔹 Checking if resource group '${resourceGroup}' exists...`)
85109
;
86110
const resourceGroupExists = await checkIfResourceGroupExists(resourceGroup);
111+
87112
if (!resourceGroupExists) {
88113
throw new Error(`Resource group '${resourceGroup}' does not exist.`);
114+
} else {
115+
console.log(`✅ Resource group '${resourceGroup}' exists.`);
89116
}
90117

91118
// Check if the workspace exists
@@ -95,17 +122,19 @@ try {
95122

96123
if (!workspaceExists) {
97124
throw new Error(`Workspace '${workspaceName}' does not exist in resource group '${resourceGroup}'.`);
125+
} else {
126+
console.log(`✅ Workspace '${workspaceName}' exists in resource group '${resourceGroup}'.`);
98127
}
99128

100129
console.log(`🔹 Checking if endpoint '${endpointName}' exists...`);
101-
const exists = await endpointExists(
130+
const exists = await checkIfEndpointExists(
102131
endpointName, resourceGroup, workspaceName
103132
);
104133

105134
if (exists) {
106135
console.log(`✅ Endpoint '${endpointName}' already exists. Skipping creation.`);
107136
} else {
108-
console.log(`🔹 Creating endpoint '${endpointName}'...`);
137+
console.log(`🔹 Endpoint does not exist, creating it ...`)
109138
await exec.exec(`az ml online-endpoint create --name ${endpointName} --resource-group ${resourceGroup} --workspace-name ${workspaceName}`);
110139
console.log(`✅ Successfully created endpoint: ${endpointName}`);
111140
}

0 commit comments

Comments
 (0)