New-AzContainerApp
Skapa en containerapp.
Syntax
New-AzContainerApp
-Name <String>
-ResourceGroupName <String>
[-SubscriptionId <String>]
-Location <String>
[-Configuration <IConfiguration>]
[-EnvironmentId <String>]
[-ExtendedLocationName <String>]
[-ExtendedLocationType <String>]
[-EnableSystemAssignedIdentity]
[-ManagedBy <String>]
[-ManagedEnvironmentId <String>]
[-ScaleMaxReplica <Int32>]
[-ScaleMinReplica <Int32>]
[-ScaleRule <IScaleRule[]>]
[-Tag <Hashtable>]
[-TemplateContainer <IContainer[]>]
[-TemplateInitContainer <IInitContainer[]>]
[-TemplateRevisionSuffix <String>]
[-TemplateServiceBind <IServiceBind[]>]
[-TemplateTerminationGracePeriodSecond <Int64>]
[-TemplateVolume <IVolume[]>]
[-UserAssignedIdentity <String[]>]
[-WorkloadProfileName <String>]
[-DefaultProfile <PSObject>]
[-AsJob]
[-NoWait]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzContainerApp
-Name <String>
-ResourceGroupName <String>
[-SubscriptionId <String>]
-JsonFilePath <String>
[-DefaultProfile <PSObject>]
[-AsJob]
[-NoWait]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzContainerApp
-Name <String>
-ResourceGroupName <String>
[-SubscriptionId <String>]
-JsonString <String>
[-DefaultProfile <PSObject>]
[-AsJob]
[-NoWait]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
New-AzContainerApp
-InputObject <IAppIdentity>
-Location <String>
[-Configuration <IConfiguration>]
[-EnvironmentId <String>]
[-ExtendedLocationName <String>]
[-ExtendedLocationType <String>]
[-EnableSystemAssignedIdentity]
[-ManagedBy <String>]
[-ManagedEnvironmentId <String>]
[-ScaleMaxReplica <Int32>]
[-ScaleMinReplica <Int32>]
[-ScaleRule <IScaleRule[]>]
[-Tag <Hashtable>]
[-TemplateContainer <IContainer[]>]
[-TemplateInitContainer <IInitContainer[]>]
[-TemplateRevisionSuffix <String>]
[-TemplateServiceBind <IServiceBind[]>]
[-TemplateTerminationGracePeriodSecond <Int64>]
[-TemplateVolume <IVolume[]>]
[-UserAssignedIdentity <String[]>]
[-WorkloadProfileName <String>]
[-DefaultProfile <PSObject>]
[-AsJob]
[-NoWait]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
Skapa en containerapp.
Exempel
Exempel 1: Skapa en containerapp för hanterad miljö.
New-AzOperationalInsightsWorkspace -ResourceGroupName azps_test_group_app -Name workspace-azpstestgp -Sku PerGB2018 -Location eastus -PublicNetworkAccessForIngestion "Enabled" -PublicNetworkAccessForQuery "Enabled"
$CustomId = (Get-AzOperationalInsightsWorkspace -ResourceGroupName azps_test_group_app -Name workspace-azpstestgp).CustomerId
$SharedKey = (Get-AzOperationalInsightsWorkspaceSharedKey -ResourceGroupName azps_test_group_app -Name workspace-azpstestgp).PrimarySharedKey
$workloadProfile = New-AzContainerAppWorkloadProfileObject -Name "Consumption" -Type "Consumption"
New-AzContainerAppManagedEnv -Name azps-env -ResourceGroupName azps_test_group_app -Location eastus -AppLogConfigurationDestination "log-analytics" -LogAnalyticConfigurationCustomerId $CustomId -LogAnalyticConfigurationSharedKey $SharedKey -VnetConfigurationInternal:$false -WorkloadProfile $workloadProfile
$EnvId = (Get-AzContainerAppManagedEnv -ResourceGroupName azps_test_group_app -Name azps-env).Id
New-SelfSignedCertificate -DnsName "www.fabrikam.com", "www.contoso.com" -CertStoreLocation "cert:\LocalMachine\My"
Get-ChildItem -Path cert:\LocalMachine\My
$mypwd = ConvertTo-SecureString -String "****" -AsPlainText -Force
Get-ChildItem -Path cert:\localMachine\my\F61C9A8C53D0500F819463A66C5921AA09E1B787 | Export-PfxCertificate -FilePath C:\mypfx.pfx -Password $mypwd
New-AzContainerAppManagedEnvCert -EnvName azps-env -Name azps-env-cert -ResourceGroupName azps_test_group_app -Location eastus -InputFile "C:\mypfx.pfx" -Password $mypwd
$trafficWeight = New-AzContainerAppTrafficWeightObject -Label "production" -Weight 100 -LatestRevision:$True
$iPSecurityRestrictionRule = New-AzContainerAppIPSecurityRestrictionRuleObject -Action "Allow" -IPAddressRange "192.168.1.1/32" -Name "Allow work IP A subnet"
$secretObject = New-AzContainerAppSecretObject -Name "redis-config" -Value "redis-password"
$customDomain = New-AzContainerAppCustomDomainObject -Name "mycertweb.com" -BindingType Disabled
$configuration = New-AzContainerAppConfigurationObject -IngressCustomDomain $customDomain -IngressIPSecurityRestriction $iPSecurityRestrictionRule -IngressTraffic $trafficWeight -IngressExternal:$True -IngressTargetPort 80 -IngressClientCertificateMode "accept" -CorPolicyAllowedOrigin "https://a.test.com","https://b.test.com" -CorPolicyAllowedMethod "GET","POST" -CorPolicyAllowedHeader "HEADER1","HEADER2" -CorPolicyExposeHeader "HEADER3","HEADER4" -CorPolicyMaxAge 1234 -CorPolicyAllowCredentials:$True -DaprEnabled:$True -DaprAppPort 3000 -DaprAppProtocol "http" -DaprHttpReadBufferSize 30 -DaprHttpMaxRequestSize 10 -DaprLogLevel "debug" -DaprEnableApiLogging:$True -MaxInactiveRevision 10 -ServiceType "redis" -Secret $secretObject
$serviceBind = New-AzContainerAppServiceBindObject -Name "redisService" -ServiceId "/subscriptions/{subId}/resourceGroups/azps_test_group_app/providers/Microsoft.App/containerApps/azps-containerapp-1"
$probeHttpGetHttpHeader = New-AzContainerAppProbeHeaderObject -Name "Custom-Header" -Value "Awesome"
$probe = New-AzContainerAppProbeObject -Type "Liveness" -HttpGetPath "/health" -HttpGetPort 8080 -InitialDelaySecond 3 -PeriodSecond 3 -HttpGetHttpHeader $probeHttpGetHttpHeader
$temp = New-AzContainerAppTemplateObject -Image "mcr.microsoft.com/k8se/quickstart-jobs:latest" -Name "simple-hello-world-container" -Probe $probe -ResourceCpu 0.25 -ResourceMemory "0.5Gi"
$temp2 = New-AzContainerAppInitContainerTemplateObject -Image "mcr.microsoft.com/k8se/quickstart-jobs:latest" -Name "simple-hello-world-container2" -ResourceCpu 0.25 -ResourceMemory "0.5Gi" -Command "/bin/sh" -Arg "-c","echo hello; sleep 10;"
New-AzContainerApp -Name "azps-containerapp-1" -ResourceGroupName "azps_test_group_app" -Location "eastus" -Configuration $configuration -TemplateContainer $temp -TemplateInitContainer $temp2 -TemplateServiceBind $serviceBind -EnvironmentId $EnvId
Location Name ResourceGroupName
-------- ---- -----------------
East US azps-containerapp-1 azps_test_group_app
Skapa en containerapp för hanterad miljö.
Exempel 2: Skapa en containerapp för ansluten miljö.
# Here you need to provide the resource "CustomLocation", for more information on how to create a resource CustomLocation, please refer to the help file: https://learn.microsoft.com/en-us/azure/container-apps/azure-arc-enable-cluster?tabs=azure-powershell
New-AzContainerAppConnectedEnv -Name azps-connectedenv -ResourceGroupName azps_test_group_app -Location eastus -ExtendedLocationName "/subscriptions/{subId}/resourceGroups/azps_test_group_app/providers/Microsoft.ExtendedLocation/customLocations/my-custom-location" -ExtendedLocationType CustomLocation
$EnvId = (Get-AzContainerAppConnectedEnv -ResourceGroupName azps_test_group_app -Name azps-connectedenv).Id
New-SelfSignedCertificate -DnsName "www.fabrikam.com", "www.contoso.com" -CertStoreLocation "cert:\LocalMachine\My"
Get-ChildItem -Path cert:\LocalMachine\My
$mypwd = ConvertTo-SecureString -String "****" -AsPlainText -Force
Get-ChildItem -Path cert:\localMachine\my\F61C9A8C53D0500F819463A66C5921AA09E1B787 | Export-PfxCertificate -FilePath C:\mypfx.pfx -Password $mypwd
New-AzContainerAppConnectedEnvCert -Name azps-connectedenvcert -ConnectedEnvironmentName azps-connectedenv -ResourceGroupName azps_test_group_app -Location eastus -InputFile "C:\mypfx.pfx" -Password $mypwd
$trafficWeight = New-AzContainerAppTrafficWeightObject -Label "production" -Weight 100 -LatestRevision:$True
$secretObject = New-AzContainerAppSecretObject -Name "redis-config" -Value "redis-password"
$configuration = New-AzContainerAppConfigurationObject -IngressTraffic $trafficWeight -IngressExternal:$True -IngressTargetPort 80 -Secret $secretObject
$temp = New-AzContainerAppTemplateObject -Image "mcr.microsoft.com/k8se/quickstart-jobs:latest" -Name "simple-hello-world-container" -ResourceCpu 0.25 -ResourceMemory "0.5Gi"
$temp2 = New-AzContainerAppInitContainerTemplateObject -Image "mcr.microsoft.com/k8se/quickstart-jobs:latest" -Name "simple-hello-world-container2" -ResourceCpu 0.25 -ResourceMemory "0.5Gi" -Command "/bin/sh" -Arg "-c","echo hello; sleep 10;"
New-AzContainerApp -Name "azps-containerapp-2" -ResourceGroupName "azps_test_group_app" -Location "eastus" -Configuration $configuration -TemplateContainer $temp -TemplateInitContainer $temp2 -EnvironmentId $EnvId -ExtendedLocationName "/subscriptions/{subId}/resourceGroups/azps_test_group_app/providers/Microsoft.ExtendedLocation/customLocations/my-custom-location" -ExtendedLocationType CustomLocation
Location Name ResourceGroupName
-------- ---- -----------------
East US azps-containerapp-2 azps_test_group_app
Skapa en containerapp för ansluten miljö.
Parametrar
-AsJob
Kör kommandot som ett jobb
Typ: | SwitchParameter |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-Configuration
Konfigurationsegenskaper för containerappar som inte är versioner.
Typ: | IConfiguration |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-Confirm
Uppmanar dig att bekräfta innan du kör cmdleten.
Typ: | SwitchParameter |
Alias: | cf |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-DefaultProfile
Parametern DefaultProfile fungerar inte. Använd parametern SubscriptionId när den är tillgänglig om du kör cmdleten mot en annan prenumeration.
Typ: | PSObject |
Alias: | AzureRMContext, AzureCredential |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-EnableSystemAssignedIdentity
Avgör om du vill aktivera en systemtilldelad identitet för resursen.
Typ: | SwitchParameter |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-EnvironmentId
Resurs-ID för miljön.
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-ExtendedLocationName
Namnet på den utökade platsen.
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-ExtendedLocationType
Typ av utökad plats.
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-InputObject
Identitetsparameter
Typ: | IAppIdentity |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | True |
Godkänn pipeline-indata: | True |
Godkänn jokertecken: | False |
-JsonFilePath
Sökväg till Json-fil som angetts för åtgärden Skapa
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | True |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-JsonString
Json-sträng som har angetts för åtgärden Skapa
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | True |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-Location
Den geo-plats där resursen finns
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | True |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-ManagedBy
Det fullständigt kvalificerade resurs-ID:t för resursen som hanterar den här resursen. Anger om den här resursen hanteras av en annan Azure-resurs. Om detta finns tar distributionen i fullständigt läge inte bort resursen om den tas bort från mallen eftersom den hanteras av en annan resurs.
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-ManagedEnvironmentId
Deprecated. Resurs-ID för containerappens miljö.
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-Name
Namnet på containerappen.
Typ: | String |
Alias: | ContainerAppName |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | True |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-NoWait
Kör kommandot asynkront
Typ: | SwitchParameter |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-ResourceGroupName
Namnet på resursgruppen. Namnet är skiftlägesokänsligt.
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | True |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-ScaleMaxReplica
Valfri. Maximalt antal containerrepliker. Standardvärdet är 10 om det inte anges.
Typ: | Int32 |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-ScaleMinReplica
Valfri. Minsta antal containerrepliker.
Typ: | Int32 |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-ScaleRule
Skalningsregler.
Typ: | IScaleRule[] |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-SubscriptionId
ID för målprenumerationen.
Typ: | String |
Position: | Named |
Standardvärde: | (Get-AzContext).Subscription.Id |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-Tag
Resurstaggar.
Typ: | Hashtable |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-TemplateContainer
Lista över containerdefinitioner för containerappen.
Typ: | IContainer[] |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-TemplateInitContainer
Lista över specialiserade containrar som körs före appcontainrar.
Typ: | IInitContainer[] |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-TemplateRevisionSuffix
Användarvänligt suffix som läggs till i revisionsnamnet
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-TemplateServiceBind
Lista över containerapptjänster som är bundna till appen
Typ: | IServiceBind[] |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-TemplateTerminationGracePeriodSecond
Valfri varaktighet i sekunder containerappinstansen måste avslutas korrekt. Värdet måste vara ett heltal som inte är negativt. Värdet noll anger stopp direkt via avlivningssignalen (ingen möjlighet att stänga av). Om det här värdet är noll används standard respitperioden i stället. Ange det här värdet längre än den förväntade rensningstiden för din process. Standardvärdet är 30 sekunder.
Typ: | Int64 |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-TemplateVolume
Lista över volymdefinitioner för containerappen.
Typ: | IVolume[] |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-UserAssignedIdentity
Matrisen med användartilldelade identiteter som är associerade med resursen. Elementen i matrisen är ARM-resurs-ID:er i formuläret: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}.'
Typ: | String[] |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-WhatIf
Visar vad som skulle hända om cmdleten körs. Cmdleten körs inte.
Typ: | SwitchParameter |
Alias: | wi |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
-WorkloadProfileName
Namn på arbetsbelastningsprofil som ska fästas för körning av containerappar.
Typ: | String |
Position: | Named |
Standardvärde: | None |
Obligatorisk: | False |
Godkänn pipeline-indata: | False |
Godkänn jokertecken: | False |
Indata
Utdata
Azure PowerShell