7

Azure Cloud Shell

 2 years ago
source link: https://techcommunity.microsoft.com/t5/microsoft-365-pnp-blog/azure-cloud-shell-issue-when-using-cli-for-microsoft-365/ba-p/2845590?WT_mc_id=DOP-MVP-4025064
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Azure Cloud Shell issue when using CLI for M365

Azure Cloud Shell issue when using CLI for Microsoft 365 - Workaround

Published Oct 18 2021 04:24 AM 747 Views

Azure Cloud Shell is one of the cool Azure features which will help you to execute Bash / PowerShell script from the browser. The best part is that Azure Cloud shell even supports CLI for Microsoft 365 without you need to explicitly install anything in the shell.

When you try to execute CLI for Microsoft 365 after creating a new Cloud Shell, we will get an error which is something like below,

/usr/local/lib/node_modules/@pnp/cli-microsoft365/node_modules/update-notifier/index.js:58
                        } catch {
                                ^
SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/@pnp/cli-microsoft365/dist/index.js:17:28)




It was identified by the expert team that this was because of the case where Azure Cloud Shell uses node version 8.16 as the base image. But CLI for Microsoft 365 uses later Node version which is causing the issue in Azure Cloud Shell. Due to this Node version mismatch, CLI for Microsoft 365 is unable to work as expected. The conversation related to this already initiated as an Issue in GitHub.

But till the time upgrade is complete, we have a workaround which could be implemented so that you can execute CLI for Microsoft 365 in Azure Cloud Shell seamlessly.

Workaround

Though the team is actively working on updating the node version, we will not be able to use Azure shell for CLI for M365 till the upgrade is complete. We do have a workaround for the same using the node on top of Node Version Manager aka NVM. You can follow the below steps if you want to know the complete steps





This is just a workaround till we have a permanent solution from Azure Shell team for the same.

You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.

%3CLINGO-SUB%20id%3D%22lingo-sub-2845590%22%20slang%3D%22en-US%22%3EAzure%20Cloud%20Shell%20issue%20when%20using%20CLI%20for%20Microsoft%20365%20-%20Workaround%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2845590%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fcloud-shell%2Foverview%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EAzure%20Cloud%20Shell%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20one%20of%20the%20cool%20Azure%20features%20which%20will%20help%20you%20to%20execute%20Bash%20%2F%20PowerShell%20script%20from%20the%20browser.%20The%20best%20part%20is%20that%20Azure%20Cloud%20shell%20even%20supports%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Faka.ms%2Fcli-m365%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ECLI%20for%20Microsoft%20365%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ewithout%20you%20need%20to%20explicitly%20install%20anything%20in%20the%20shell.%3C%2FP%3E%0A%3CP%3EWhen%20you%20try%20to%20execute%20CLI%20for%20Microsoft%20365%20after%20creating%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fcloud-shell%2Fquickstart%23start-cloud-shell%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Enew%20Cloud%20Shell%3C%2FA%3E%2C%20we%20will%20get%20an%20error%20which%20is%20something%20like%20below%2C%3C%2FP%3E%0A%3CDIV%20class%3D%22language-powershell%20highlighter-rouge%22%3E%0A%3CDIV%20class%3D%22highlight%22%3E%0A%3CPRE%20class%3D%22highlight%22%3E%3CCODE%3E%3CSPAN%20class%3D%22n%22%3E%2Fusr%2Flocal%2Flib%2Fnode_modules%2F%3C%2FSPAN%3E%3CSPAN%20class%3D%22err%22%3E%40%3C%2FSPAN%3E%3CSPAN%20class%3D%22nx%22%3Epnp%2Fcli-microsoft365%2Fnode_modules%2Fupdate-notifier%2Findex.js%3A58%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22p%22%3E%7D%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22kr%22%3Ecatch%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22p%22%3E%7B%3C%2FSPAN%3E%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3CSPAN%20class%3D%22err%22%3E%5E%3C%2FSPAN%3E%0A%3CSPAN%20class%3D%22n%22%3ESyntaxError%3A%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3EUnexpected%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3Etoken%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22p%22%3E%7B%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22n%22%3Eat%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3EcreateScript%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22p%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22n%22%3Evm.js%3A80%3A10%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E)%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22n%22%3Eat%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3EObject.runInThisContext%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22p%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22n%22%3Evm.js%3A139%3A10%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E)%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22n%22%3Eat%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3EModule._compile%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22p%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22n%22%3Emodule.js%3A617%3A28%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E)%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22n%22%3Eat%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3EObject.Module._extensions..js%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22p%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22n%22%3Emodule.js%3A664%3A10%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E)%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22n%22%3Eat%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3EModule.load%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22p%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22n%22%3Emodule.js%3A566%3A32%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E)%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22n%22%3Eat%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3EtryModuleLoad%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22p%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22n%22%3Emodule.js%3A506%3A12%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E)%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22n%22%3Eat%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3EFunction.Module._load%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22p%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22n%22%3Emodule.js%3A498%3A3%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E)%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22n%22%3Eat%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3EModule.require%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22p%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22n%22%3Emodule.js%3A597%3A17%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E)%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22n%22%3Eat%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3Erequire%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22p%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22n%22%3Einternal%2Fmodule.js%3A11%3A18%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E)%3C%2FSPAN%3E%0A%20%20%20%20%3CSPAN%20class%3D%22n%22%3Eat%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22nx%22%3EObject.%3C%2FSPAN%3E%3CSPAN%20class%3D%22err%22%3E%26lt%3B%3C%2FSPAN%3E%3CSPAN%20class%3D%22nx%22%3Eanonymous%3C%2FSPAN%3E%3CSPAN%20class%3D%22err%22%3E%26gt%3B%3C%2FSPAN%3E%20%3CSPAN%20class%3D%22p%22%3E(%3C%2FSPAN%3E%3CSPAN%20class%3D%22n%22%3E%2Fusr%2Flocal%2Flib%2Fnode_modules%2F%3C%2FSPAN%3E%3CSPAN%20class%3D%22err%22%3E%40%3C%2FSPAN%3E%3CSPAN%20class%3D%22nx%22%3Epnp%2Fcli-microsoft365%2Fdist%2Findex.js%3A17%3A28%3C%2FSPAN%3E%3CSPAN%20class%3D%22p%22%3E)%3C%2FSPAN%3E%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FDIV%3E%0A%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ArjunMenon_0-1634207520847.jpeg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F317308i66F0197FACFEBEE0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22ArjunMenon_0-1634207520847.jpeg%22%20alt%3D%22ArjunMenon_0-1634207520847.jpeg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%20was%20identified%20by%20the%20expert%20team%20that%20this%20was%20because%20of%20the%20case%20where%20Azure%20Cloud%20Shell%20uses%20node%20version%208.16%20as%20the%20base%20image.%20But%20CLI%20for%20Microsoft%20365%20uses%20later%20Node%20version%20which%20is%20causing%20the%20issue%20in%20Azure%20Cloud%20Shell.%20Due%20to%20this%20Node%20version%20mismatch%2C%20CLI%20for%20Microsoft%20365%20is%20unable%20to%20work%20as%20expected.%20The%20conversation%20related%20to%20this%20already%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2FCloudShell%2Fissues%2F63%23issuecomment-746877238%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Einitiated%20as%20an%20Issue%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ein%20GitHub.%3C%2FP%3E%0A%3CP%20data-unlink%3D%22true%22%3EBut%20till%20the%20time%20upgrade%20is%20complete%2C%20we%20have%20a%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eworkaround%26nbsp%3Bwhich%20could%20be%20implemented%20so%20that%20you%20can%20execute%20CLI%20for%20Microsoft%20365%20in%20Azure%20Cloud%20Shell%20seamlessly.%3C%2FP%3E%0A%3CH2%20id%3D%22workaround%22%20id%3D%22toc-hId--324710523%22%20id%3D%22toc-hId--323758202%22%3EWorkaround%3C%2FH2%3E%0A%3CP%3EThough%20the%20team%20is%20actively%20working%20on%20updating%20the%20node%20version%2C%20we%20will%20not%20be%20able%20to%20use%20Azure%20shell%20for%20CLI%20for%20M365%20till%20the%20upgrade%20is%20complete.%20We%20do%20have%20a%20workaround%20for%20the%20same%20using%20the%20node%20on%20top%20of%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnvm-sh%2Fnvm%23intro%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3ENode%20Version%20Manager%20aka%20NVM%3C%2FA%3E.%20You%20can%20follow%20the%20below%20steps%20if%20you%20want%20to%20know%20the%20complete%20steps%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnvm-sh%2Fnvm%23install--update-script%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EInstall%20NVM%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ein%20the%20cloud%20shell%3C%2FLI%3E%0A%3CLI%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnvm-sh%2Fnvm%23intro%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EInstall%20the%20Node%20version%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Erequired%20for%20CLI%20for%20Microsoft%20365.%20As%20of%20writing%20this%20blog%2C%20CLI%20for%20Microsoft%20365%20supports%20any%20node%20version%26gt%3B14.0.0%3COL%3E%0A%3CLI%3E%3CCODE%20class%3D%22language-plaintext%20highlighter-rouge%22%3Envm%20install%2014.0.0%3C%2FCODE%3E%3C%2FLI%3E%0A%3CLI%3E%3CEM%3EMade%20sure%20you%20are%20making%20this%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fnvm-sh%2Fnvm%23set-default-node-version%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Eversion%20as%20default%3C%2FA%3E%3C%2FEM%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FLI%3E%0A%3CLI%3EAfter%20that%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fpnp.github.io%2Fcli-microsoft365%2Fuser-guide%2Finstalling-cli%2F%23install-the-cli-for-microsoft-365%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Einstall%20CLI%20for%20Microsoft%20365%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ein%20the%20node%20version%20which%20you%20have%20set%20as%20the%20default%3C%2FLI%3E%0A%3CLI%3EOnce%20the%20CLI%20package%20is%20installed%2C%20you%20can%20see%20that%20CLI%20works%20perfectly%20well%20in%20Azure%20Shell%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22ArjunMenon_1-1634207520863.jpeg%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F317309i704543BF73EC8BA0%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22ArjunMenon_1-1634207520863.jpeg%22%20alt%3D%22ArjunMenon_1-1634207520863.jpeg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20just%20a%20workaround%20till%20we%20have%20a%20permanent%20solution%20from%20Azure%20Shell%20team%20for%20the%20same.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2845590%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%3EBlog%20which%20gives%20you%20a%20workaround%20for%20the%20issue%20in%20Azure%20Cloud%20Shell%20when%20you%20try%20to%20run%20CLI%20for%20Microsoft%20365%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2845590%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EHow%20to%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E

Version history
Last update:

‎Oct 14 2021 03:36 AM

Updated by:
Labels

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK