“无法识别'New-AzureStorageContext',"尚未安装模块 [英] "'New-AzureStorageContext' is not recognized," Yet the Module is Installed
问题描述
I have installed both the Az PowerShell module and .NET Framework 4.7.2 per the instructions at https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-1.0.0 yet the client still can't find the module!
PS C:\Scripts> get-module Az
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.1 Az
PS C:\Scripts> get-module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.1 Az
Script 1.0.0 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Conn...
Script 1.0.0 Az.Aks {Get-AzAks, Import-AzAksCredential, New-AzAks, Remove-AzAk...
Script 1.0.0 Az.AnalysisServices {Add-AzAnalysisServicesAccount, Export-AzAnalysisServicesI...
Script 1.0.0 Az.ApiManagement {Add-AzApiManagementApiToProduct, Add-AzApiManagementProdu...
Script 1.0.0 Az.ApplicationInsights {Get-AzApplicationInsights, Get-AzApplicationInsightsApiKe...
Script 1.0.0 Az.Automation {Export-AzAutomationDscConfiguration, Export-AzAutomationD...
Script 1.0.0 Az.Batch {Disable-AzBatchAutoScale, Disable-AzBatchComputeNodeSched...
Script 1.0.0 Az.Billing {Get-AzBillingInvoice, Get-AzBillingPeriod, Get-AzConsumpt...
Script 1.0.0 Az.Cdn {Confirm-AzCdnEndpointProbeURL, Disable-AzCdnCustomDomain,...
Script 1.0.0 Az.CognitiveServices {Get-AzCognitiveServicesAccount, Get-AzCognitiveServicesAc...
Script 1.0.0 Az.Compute {Add-AzContainerServiceAgentPoolProfile, Add-AzImageDataDi...
Script 1.0.0 Az.ContainerInstance {Get-AzContainerGroup, Get-AzContainerInstanceLog, New-AzC...
Script 1.0.0 Az.ContainerRegistry {Get-AzContainerRegistry, Get-AzContainerRegistryCredentia...
Script 1.0.0 Az.DataFactory {Get-AzDataFactory, Get-AzDataFactoryActivityWindow, Get-A...
Script 1.0.0 Az.DataLakeAnalytics {Add-AzDataLakeAnalyticsDataSource, Add-AzDataLakeAnalytic...
Script 1.0.0 Az.DataLakeStore {Add-AzDataLakeStoreFirewallRule, Add-AzDataLakeStoreItemC...
Script 1.0.0 Az.DevTestLabs {Get-AzDtlAllowedVMSizesPolicy, Get-AzDtlAutoShutdownPolic...
Script 1.0.0 Az.Dns {Add-AzDnsRecordConfig, Get-AzDnsRecordSet, Get-AzDnsZone,...
Script 1.0.0 Az.EventGrid {Get-AzEventGridSubscription, Get-AzEventGridTopic, Get-Az...
Script 1.0.0 Az.EventHub {Get-AzEventHub, Get-AzEventHubAuthorizationRule, Get-AzEv...
Script 1.0.0 Az.HDInsight {Add-AzHDInsightClusterIdentity, Add-AzHDInsightComponentV...
Script 1.0.0 Az.IotHub {Add-AzIotHubCertificate, Add-AzIotHubEventHubConsumerGrou...
Script 1.0.0 Az.KeyVault {Add-AzKeyVaultCertificate, Add-AzKeyVaultCertificateConta...
Script 1.0.0 Az.LogicApp {Get-AzIntegrationAccount, Get-AzIntegrationAccountAgreeme...
Script 1.0.0 Az.MachineLearning {Add-AzMlWebServiceRegionalProperty, Export-AzMlWebService...
Script 1.0.0 Az.MarketplaceOrdering {Get-AzMarketplaceTerms, Set-AzMarketplaceTerms}
Script 1.0.0 Az.Media {Get-AzMediaService, Get-AzMediaServiceKeys, Get-AzMediaSe...
Script 1.0.0 Az.Monitor {Add-AzAutoscaleSetting, Add-AzLogProfile, Add-AzMetricAle...
Script 1.0.0 Az.Network {Add-AzApplicationGatewayAuthenticationCertificate, Add-Az...
Script 1.0.0 Az.NotificationHubs {Get-AzNotificationHub, Get-AzNotificationHubAuthorization...
Script 1.0.0 Az.OperationalInsights {Disable-AzOperationalInsightsIISLogCollection, Disable-Az...
Script 1.0.0 Az.PolicyInsights {Get-AzPolicyEvent, Get-AzPolicyRemediation, Get-AzPolicyS...
Script 1.0.0 Az.PowerBIEmbedded {Get-AzPowerBIEmbeddedCapacity, Get-AzPowerBIWorkspace, Ge...
Script 1.0.0 Az.RecoveryServices {Backup-AzRecoveryServicesBackupItem, Disable-AzRecoverySe...
Script 1.0.0 Az.RedisCache {Export-AzRedisCache, Get-AzRedisCache, Get-AzRedisCacheFi...
Script 1.0.0 Az.Relay {Get-AzRelayAuthorizationRule, Get-AzRelayHybridConnection...
Script 1.0.0 Az.Resources {Add-AzADGroupMember, Export-AzResourceGroup, Get-AzADAppC...
Script 1.0.0 Az.ServiceBus {Complete-AzServiceBusMigration, Get-AzServiceBusAuthoriza...
Script 1.0.0 Az.ServiceFabric {Add-AzServiceFabricApplicationCertificate, Add-AzServiceF...
Script 1.0.0 Az.SignalR {Get-AzSignalR, Get-AzSignalRKey, New-AzSignalR, New-AzSig...
Script 1.0.0 Az.Sql {Add-AzSqlDatabaseToFailoverGroup, Add-AzSqlManagedInstanc...
Script 1.0.0 Az.Storage {Add-AzRmStorageContainerLegalHold, Add-AzStorageAccountNe...
Script 1.0.0 Az.StreamAnalytics {Get-AzStreamAnalyticsDefaultFunctionDefinition, Get-AzStr...
Script 1.0.0 Az.TrafficManager {Add-AzTrafficManagerCustomHeaderToEndpoint, Add-AzTraffic...
Script 1.0.0 Az.Websites {Edit-AzWebAppBackupConfiguration, Enter-AzWebAppContainer...
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest 3.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl...
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest 3.0.0.0 Microsoft.WSMan.Management {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, En...
Binary 1.0.0.1 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-Pack...
Script 1.0.0.1 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Find-RoleCap...
Script 1.2 PSReadline {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PS...
PS C:\Scripts> $context = New-AzureStorageContext -StorageAccountName "...my storage account name..." -StorageAccountKey "...my sas key..."
New-AzureStorageContext : The term 'New-AzureStorageContext' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:12
+ $context = New-AzureStorageContext -StorageAccountName "...my storage acc...
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (New-AzureStorageContext:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
错误(如上面的输出所示)是:
The error (as shown above in the output above) is:
New-AzureStorageContext:术语"New-AzureStorageContext"不是识别为cmdlet,函数的名称,脚本文件或可操作程序.检查名称的拼写,或者是否包含路径,请验证该路径是否为更正并重试.
New-AzureStorageContext : The term 'New-AzureStorageContext' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
我在这里想念东西吗?
推荐答案
命令 AzureRM
powershell模块,它与新模块 Az
,没有安装它,导致了问题.
The command New-AzureStorageContext
you used belongs to the AzureRM
powershell module, it is different from the new module Az
, you have not installed it, that caused the issue.
要解决此问题,您可以参考以下解决方案.
To fix the issue, you could refer to the solutions below.
1.Install the AzureRM
module.
2.如果要使用 Az
运行为 AzureRM
开发的脚本,请使用 Enable/Disable-AzureRmAlias
cmdlet添加或删除从AzureRM cmdlet到Az cmdlet的别名.
2.If you want to run scripts developed for AzureRM
using Az
, use the Enable/Disable-AzureRmAlias
cmdlets to add or remove aliases from AzureRM cmdlets to Az cmdlets.
将给定模块(或所有模块,如果未指定模块的话)的AzureRM cmdlet别名添加到当前会话(默认),当前用户的所有会话或计算机上的所有会话.
Adds AzureRM cmdlet aliases for the given modules (or all modules if no modules are specified) to the current session (default), all sessions for the current user, or all session on the machine.
Enable-AzureRmAlias [-Module <string>] [-Scope Process | CurrentUser | LocalMachine]
Disable-AzureRmAlias [-Module <string[]>] [-Scope Process | CurrentUser | LocalMachine]
3.使用 New-AzStorageContext 而不是 New-AzureStorageContext
,基本上不推荐使用 AzureRM
模块,从本质上讲,它们称为相同的api都用于ARM,您可以尝试一下.
3.Use New-AzStorageContext
instead of New-AzureStorageContext
, it is recommended, the AzureRM
module is basically deprecated, essentially they call the same api and are all for ARM, you could have a try.
有关更多详细信息,请参见:.
For more details, see : Azure PowerShell – Cross-platform "Az" module replacing "AzureRM".
这篇关于“无法识别'New-AzureStorageContext',"尚未安装模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!