你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Import-AzApiManagementApi
Imports an API from a file or a URL.
Syntax
Import-AzApiManagementApi
-Context <PsApiManagementContext>
[-ApiId <String>]
[-ApiRevision <String>]
-SpecificationFormat <PsApiManagementApiFormat>
-SpecificationPath <String>
[-Path <String>]
[-WsdlServiceName <String>]
[-WsdlEndpointName <String>]
[-ApiType <PsApiManagementApiType>]
[-Protocol <PsApiManagementSchema[]>]
[-ServiceUrl <String>]
[-ApiVersionSetId <String>]
[-ApiVersion <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Import-AzApiManagementApi
-Context <PsApiManagementContext>
[-ApiId <String>]
[-ApiRevision <String>]
-SpecificationFormat <PsApiManagementApiFormat>
-SpecificationUrl <String>
[-Path <String>]
[-WsdlServiceName <String>]
[-WsdlEndpointName <String>]
[-ApiType <PsApiManagementApiType>]
[-Protocol <PsApiManagementSchema[]>]
[-ServiceUrl <String>]
[-ApiVersionSetId <String>]
[-ApiVersion <String>]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
Description
The Import-AzApiManagementApi cmdlet imports an Azure API Management API from a file or a URL in Web Application Description Language (WADL), Web Services Description Language (WSDL), or Swagger format.
Examples
Example 1: Import an API from a WADL file
$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
Import-AzApiManagementApi -Context $ApiMgmtContext -SpecificationFormat "Wadl" -SpecificationPath "C:\contoso\specifications\echoapi.wadl" -Path "apis"
This command imports an API from the specified WADL file.
Example 2: Import an API from a Swagger file
$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
Import-AzApiManagementApi -Context $ApiMgmtContext -SpecificationFormat "Swagger" -SpecificationPath "C:\contoso\specifications\echoapi.swagger" -Path "apis"
This command imports an API from the specified Swagger file.
Example 3: Import an API from a Swagger file and update an existing API
$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
Import-AzApiManagementApi -Context $ApiMgmtContext -ApiId "26591405e27d4ff3a8d8478d7e60c7b0" -SpecificationFormat "Swagger" -SpecificationPath "C:\contoso\specifications\echoapi.swagger" -Path "apis"
This command imports an API from the specified Swagger file and updates an existing API.
Example 4: Import an API from a WADL link
$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
Import-AzApiManagementApi -Context $ApiMgmtContext -SpecificationFormat "Wadl" -SpecificationUrl "http://contoso.com/specifications/wadl/echoapi" -Path "apis"
This command imports an API from the specified WADL link.
Example 5: Import an API from a Open Api Link
$context = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
Import-AzApiManagementApi -Context $context -SpecificationFormat OpenApi -SpecificationUrl https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml -Path "petstore30"
ApiId : af3f57bab399455aa875d7050654e9d1
Name : Swagger Petstore
Description :
ServiceUrl : http://petstore.swagger.io/v1
Path : petstore30
ApiType : http
Protocols : {Https}
AuthorizationServerId :
AuthorizationScope :
OpenidProviderId :
BearerTokenSendingMethod : {}
SubscriptionKeyHeaderName : Ocp-Apim-Subscription-Key
SubscriptionKeyQueryParamName : subscription-key
ApiRevision : 1
ApiVersion :
IsCurrent : True
IsOnline : False
SubscriptionRequired :
ApiRevisionDescription :
ApiVersionSetDescription :
ApiVersionSetId :
Id : /subscriptions/subid/resourceGroups/Api-Default-West-US/providers/Microsoft.ApiManagement/service/contoso/apis/af3f57bab399455aa875d7050654e9d1
ResourceGroupName : Api-Default-West-US
ServiceName : contoso
This command imports an API from the specified Open 3.0 specification link.
Example 6: Import an API from a Open Api Link into a ApiVersion Set
$context = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
Import-AzApiManagementApi -Context $context -SpecificationPath "C:\contoso\specifications\uspto.yml" -SpecificationFormat OpenApi -Path uspostal -ApiVersionSetId 0d50e2cf-aaeb-4ea3-8a58-db9ec079c6cd -ApiVersion v2
ApiId : 6c3f20c66e5745b19229d06cd865948f
Name : USPTO Data Set API
Description : The Data Set API (DSAPI) allows the public users to discover and search USPTO exported data sets. This is a generic API that allows USPTO users to make any CSV based data files
searchable through API. With the help of GET call, it returns the list of data fields that are searchable. With the help of POST call, data can be fetched based on the filters on the
field names. Please note that POST call is used to search the actual data. The reason for the POST call is that it allows users to specify any complex search criteria without worry
about the GET size limitations as well as encoding of the input parameters.
ServiceUrl : https://developer.uspto.gov/ds-api
Path : uspostal
ApiType : http
Protocols : {Https}
AuthorizationServerId :
AuthorizationScope :
OpenidProviderId :
BearerTokenSendingMethod : {}
SubscriptionKeyHeaderName : Ocp-Apim-Subscription-Key
SubscriptionKeyQueryParamName : subscription-key
ApiRevision : 1
ApiVersion : v2
IsCurrent : True
IsOnline : False
SubscriptionRequired :
ApiRevisionDescription :
ApiVersionSetDescription :
ApiVersionSetId : /subscriptions/subid/resourceGroups/Api-Default-East-US/providers/Microsoft.ApiManagement/service/contoso/apiVersionSets/0d50e2cf-aaeb-4ea3-8a58-db9ec079c6cd
Id : /subscriptions/subid/resourceGroups/Api-Default-East-US/providers/Microsoft.ApiManagement/service/contoso/apis/6c3f20c66e5745b19229d06cd865948f
ResourceGroupName : Api-Default-East-US
ServiceName : contoso
This command imports an API from the specified Open 3.0 specification document and create a new ApiVersion.
Example 7: Import an API from a GraphQL link
$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName "Api-Default-WestUS" -ServiceName "contoso"
Import-AzApiManagementApi -Context $ApiMgmtContext -SpecificationFormat "GraphQL" -SpecificationUrl "http://contoso.com/graphql" -Path "graphqlapi"
ApiId : bg4g23csd067432zz853f0942341g3z1
Name : GraphQL Api
Description :
ServiceUrl : http://contoso.com/graphql
Path : graphqlapi
ApiType : graphql
Protocols : {Https}
AuthorizationServerId :
AuthorizationScope :
OpenidProviderId :
BearerTokenSendingMethod : {}
SubscriptionKeyHeaderName : Ocp-Apim-Subscription-Key
SubscriptionKeyQueryParamName : subscription-key
ApiRevision : 1
ApiVersion :
IsCurrent : True
IsOnline : False
SubscriptionRequired :
ApiRevisionDescription :
ApiVersionSetDescription :
ApiVersionSetId :
Id : /subscriptions/subid/resourceGroups/Api-Default-West-US/providers/Microsoft.ApiManagement/service/contoso/apis/bg4g23csd067432zz853f0942341g3z1
ResourceGroupName : Api-Default-West-US
ServiceName : contoso
This command imports an API from the GraphQL link.
Parameters
-ApiId
Specifies an ID for the API to import. If you do not specify this parameter, an ID is generated for you.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ApiRevision
Identifier of API Revision. This parameter is optional. If not specified, the import will be done onto the currently active revision or a new api.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ApiType
This parameter is optional with a default value of Http. The Soap option is only applicable when importing WSDL and will create a SOAP Passthrough API.
Type: | Nullable<T>[PsApiManagementApiType] |
Accepted values: | Http, Soap, WebSocket, GraphQL |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ApiVersion
Api Version of the Api to create. This parameter is optional.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ApiVersionSetId
A resource identifier for the related Api Version Set. This parameter is optional.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Context
Specifies a PsApiManagementContext object.
Type: | PsApiManagementContext |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-DefaultProfile
The credentials, account, tenant, and subscription used for communication with azure.
Type: | IAzureContextContainer |
Aliases: | AzContext, AzureRmContext, AzureCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Path
Specifies a web API path as the last part of the API's public URL. This URL is used by API consumers for sending requests to the web service. Must be 1 to 400 characters long. The default value is $Null.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Protocol
Web API protocols (http, https). Protocols over which API is made available. This parameter is optional. If provided it will override the protocols specified in the specifications document.
Type: | PsApiManagementSchema[] |
Accepted values: | Http, Https, Ws, Wss |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ServiceUrl
A URL of the web service exposing the API. This URL will be used by Azure API Management only, and will not be made public. This parameter is optional. If provided it will override the ServiceUrl specified in the Specifications document.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-SpecificationFormat
Specifies the specification format. psdx_paramvalues Wadl, Wsdl, and Swagger.
Type: | PsApiManagementApiFormat |
Accepted values: | Wadl, Swagger, Wsdl, OpenApi, OpenApiJson, GraphQL |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-SpecificationPath
Specifies the specification file path.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-SpecificationUrl
Specifies the specification URL.
Type: | String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-WsdlEndpointName
Local name of WSDL Endpoint (port) to be imported. Must be 1 to 400 characters long. This parameter is optional and only required for importing Wsdl. Default value is $null.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-WsdlServiceName
Local name of WSDL Service to be imported. Must be 1 to 400 characters long. This parameter is optional and only required for importing Wsdl . Default value is $null.
Type: | String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Inputs
Nullable<T>[[Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementApiType, Microsoft.Azure.PowerShell.Cmdlets.ApiManagement.ServiceManagement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]