Refactor: changed appId configuration variable to clientId.
This commit is contained in:
@@ -50,18 +50,18 @@ try {
|
||||
if (appIdList.length !== 1) {
|
||||
throw new Error("App not found or multiple apps with the same name.");
|
||||
}
|
||||
config.appId = appIdList[0].appId;
|
||||
config.clientId = appIdList[0].appId;
|
||||
} catch (error) {
|
||||
console.error("Failed to query Azure AD applications.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (config.appId) {
|
||||
console.log(`App already exists with ID: ${config.appId}`);
|
||||
if (config.clientId) {
|
||||
console.log(`App already exists with Client ID: ${config.clientId}`);
|
||||
} else {
|
||||
// Create the Azure AD application, capturing the JSON output, and extracting the .appId
|
||||
try {
|
||||
config.appId = execSync(
|
||||
config.clientId = execSync(
|
||||
`az ad app create --display-name "${config.appName}" --query "appId" -o tsv`,
|
||||
)
|
||||
.toString()
|
||||
@@ -70,15 +70,15 @@ if (config.appId) {
|
||||
console.error("Failed to create Azure AD application.");
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(`Created App with ID: ${config.appId}`);
|
||||
console.log(`Created App with Client ID: ${config.clientId}`);
|
||||
}
|
||||
|
||||
// Chech if service principal exists
|
||||
// Check if service principal exists
|
||||
let spObjId;
|
||||
|
||||
try {
|
||||
const spIdList = JSON.parse(
|
||||
execSync(`az ad sp list --filter "appId eq '${config.appId}'" -o json`)
|
||||
execSync(`az ad sp list --filter "appId eq '${config.clientId}'" -o json`)
|
||||
.toString()
|
||||
.trim(),
|
||||
);
|
||||
@@ -98,7 +98,7 @@ if (spObjId) {
|
||||
// Now create the service principal for the app
|
||||
try {
|
||||
spObjId = execSync(
|
||||
`az ad sp create --id ${config.appId} --query "id" -o tsv`,
|
||||
`az ad sp create --id ${config.clientId} --query "id" -o tsv`,
|
||||
);
|
||||
console.log("Service principal created.");
|
||||
} catch (error) {
|
||||
@@ -117,7 +117,7 @@ if (args.values["generate-client-secret"]) {
|
||||
"credential",
|
||||
"reset",
|
||||
"--id",
|
||||
config.appId,
|
||||
config.clientId,
|
||||
"--query",
|
||||
"password",
|
||||
"-o",
|
||||
@@ -138,7 +138,7 @@ if (args.values["write-env"] || args.values["generate-client-secret"]) {
|
||||
// Write the APP_ID to the .env file
|
||||
const envContent = `AZ_APP_NAME="${config.appName}"
|
||||
ARM_TENANT_ID=${config.tenantId}
|
||||
ARM_CLIENT_ID=${config.appId}
|
||||
ARM_CLIENT_ID=${config.clientId}
|
||||
ARM_CLIENT_SECRET=${config.clientSecret || ""}
|
||||
`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user