@@ -23,8 +23,10 @@ const io = __importStar(require("@actions/io"));
2323var psPath ;
2424exports . initializeAz = ( servicePrincipalId , servicePrincipalKey , tenantId , subscriptionId ) => __awaiter ( void 0 , void 0 , void 0 , function * ( ) {
2525 psPath = yield io . which ( "pwsh" , true ) ;
26+ const prefix = "az_" ;
2627 setPSModulePath ( ) ;
27- setPSModulePath ( yield getLatestModule ( ) ) ;
28+ const azLatestVersion = yield getLatestAzModule ( ) ;
29+ setPSModulePath ( `${ prefix } ${ azLatestVersion } ` ) ;
2830 yield loginToAzure ( servicePrincipalId , servicePrincipalKey , tenantId , subscriptionId ) ;
2931} ) ;
3032function setPSModulePath ( azPSVersion = "" ) {
@@ -45,7 +47,7 @@ function setPSModulePath(azPSVersion = "") {
4547 }
4648 process . env . PSModulePath = `${ modulePath } ${ process . env . PSModulePath } ` ;
4749}
48- function getLatestModule ( ) {
50+ function getLatestAzModule ( ) {
4951 return __awaiter ( this , void 0 , void 0 , function * ( ) {
5052 const moduleName = "Az.Accounts" ;
5153 let output = "" ;
@@ -62,7 +64,7 @@ function getLatestModule() {
6264 } ;
6365 yield executePowerShellCommand ( `(Get-Module -Name ${ moduleName } -ListAvailable | Sort-Object Version -Descending | Select-Object -First 1).Version.ToString()` , options ) ;
6466 core . debug ( `Az Module version used: ${ output } ` ) ;
65- return `az_ ${ output } ` ;
67+ return output ;
6668 } ) ;
6769}
6870function loginToAzure ( servicePrincipalId , servicePrincipalKey , tenantId , subscriptionId ) {
@@ -79,11 +81,6 @@ function loginToAzure(servicePrincipalId, servicePrincipalKey, tenantId, subscri
7981}
8082function executePowerShellCommand ( command , options = { } ) {
8183 return __awaiter ( this , void 0 , void 0 , function * ( ) {
82- try {
83- yield exec . exec ( `"${ psPath } " -Command "${ command } "` , [ ] , options ) ;
84- }
85- catch ( error ) {
86- throw new Error ( error ) ;
87- }
84+ yield exec . exec ( `"${ psPath } " -Command "${ command } "` , [ ] , options ) ;
8885 } ) ;
8986}
0 commit comments