Skip to content

Latest commit

 

History

History
162 lines (142 loc) · 10.9 KB

marketplace-publishing-data-service-creation-odata-mapping-examples.md

File metadata and controls

162 lines (142 loc) · 10.9 KB
title description services documentationcenter author manager editor ms.assetid ms.service ms.devlang ms.topic ms.tgt_pltfrm ms.workload ms.date ms.author
Guide to creating a Data Service for the Marketplace | Microsoft Docs
Detailed instructions of how to create, certify and deploy a Data Service for purchase on the Azure Marketplace.
marketplace-publishing
HannibalSII
hascipio
148f8638-ee80-4100-8d63-5afa4167ca1b
marketplace
na
article
na
na
08/26/2016
hascipio; avikova

Examples of mapping an existing web service to OData through CSDLs

Important

At this time we are no longer onboarding any new Data Service publishers. New dataservices will not get approved for listing. If you have a SaaS business application you would like to publish on AppSource you can find more information here. If you have an IaaS applications or developer service you would like to publish on Azure Marketplace you can find more information here.

Example: FunctionImport for "Raw" data returned using "POST"

Use POST Raw data to create a new subordinate and return its server defined URL(location) or to update part of the subordinate at the server defined URL. Where the subordinate is a stream, i.e. unstructured, ex. a text file. Beware POST in not idempotent without a location.

    <!--  No EntitySet or EntityType nodes required for Raw output-->
    <FunctionImport Name="AddUsageEvent" ReturnType="Raw(text/plain)" d:EncodeParameterValues="true" d:AllowedHttpMethods="POST" d:BaseUri="http://services.organization.net/MyServicePath?name={name}&amp;AccountKey=22AC643">
    <d:Title d:Map="" />
    <d:Rights d:Map="" />
    <d:Description>Add usage event (data acquisition)</d:Description>
    <d:Headers>
    <d:Header d:Name="Content-Type" d:Value="application/xml;charset=UTF-8" />
    </d:Headers>
    <Parameter Name="name" Nullable="false" Mode="In" Type="String" d:Description="first name" d:SampleValues="John|Joe|Bill"  d:EncodeParameterValue="true" />
    <d:Namespaces>
    <d:Namespace d:Prefix="p" d:Uri="http://schemas.organization.net/2010/04/myNamespace " />
    <d:Namespace d:Prefix="p2" d:Uri=" http://schemas.organization.net/2010/04/myNamespace2 " />
    </d:Namespaces>
    </FunctionImport>

Example: FunctionImport using "DELETE"

Use DELETE to remove a specified URI.

    <EntitySet Name="DeleteUsageFileEntitySet" EntityType="MyOffer.DeleteUsageFileEntity" />
    <FunctionImport Name="DeleteUsageFile" EntitySet="DeleteUsageFileEntitySet" ReturnType="Collection(MyOffer.DeleteUsageFileEntity)"  d:AllowedHttpMethods="DELETE" d:EncodeParameterValues="true” d:BaseUri=”http://services.organization.net/MyServicePath?name={name}&amp;AccountKey=22AC643" >
    <d:Title d:Map="" />
    <d:Rights d:Map="" />
    <d:Description>Delete usage File</d:Description>
    <d:Headers>
    <d:Header d:Name="Content-Type" d:Value="application/xml;charset=UTF-8" />
    </d:Headers>
    <Parameter Name="name" Nullable="false" Mode="In" Type="String" d:Description="first name" d:SampleValues="John|Joe|Bill"  d:EncodeParameterValue="true" />
    <d:Namespaces>
    <d:Namespace d:Prefix="p" d:Uri="http://schemas.organization.net/2010/04/myNamespace " />
    <d:Namespace d:Prefix="p2" d:Uri=" http://schemas.organization.net/2010/04/myNamespace2 " />
    </d:Namespaces>
    </FunctionImport>
    <EntityType Name="DeleteUsageFileEntity" d:Map="//boolean">
    <Property Name="boolean" Type="String" Nullable="true" d:Map="./boolean" />
    </EntityType>

Example: FunctionImport using "POST"

Use POST Raw data to create a new subordinate and return its server defined URL(location) or to update part of the subordinate at the server defined URL. Where the subordinate is a structure. Beware POST is not idempotent without a location.

    <EntitySet Name="CreateANewModelEntitySet2" EntityType=" MyOffer.CreateANewModelEntity2" />
    <FunctionImport Name="CreateModel" EntitySet="CreateANewModelEntitySet2" ReturnType="Collection(MyOffer.CreateANewModelEntity2)" d:EncodeParameterValues="true" d:AllowedHttpMethods="POST" d:BaseUri=”http://services.organization.net/MyServicePath?name={name}&amp;AccountKey=22AC643">
    <d:Title d:Map="" />
    <d:Rights d:Map="" />
    <d:Description>Create A New Model</d:Description>
    <d:Headers>
    <d:Header d:Name="Content-Type" d:Value="application/xml;charset=UTF-8" />
    </d:Headers>
    <Parameter name="name" Nullable="false" Mode="In" Type="String" d:Description="first name" d:SampleValues="John|Joe|Bill"  d:EncodeParameterValue="true" />
    <d:Namespaces>
    <d:Namespace d:Prefix="p" d:Uri="http://schemas.organization.net/2010/04/myNamespace " />
    <d:Namespace d:Prefix="p2" d:Uri=" http://schemas.organization.net/2010/04/myNamespace2 " />
    </d:Namespaces>
    </FunctionImport>

Example: FunctionImport using "PUT"

Use PUT to create a new subordinate or to update the entire subordinate at a server defined URL. Where the subordinate is a structure, PUT is idempotent so multiple occurrences will result in the same state, i.e x=5. Put should be used with the full content of the specified resource.

    <EntitySet Name="UpdateAnExistingModelEntitySet" EntityType="MyOffer.UpdateAnExistingModelEntity" />
    <FunctionImport Name="UpdateModel" EntitySet="UpdateAnExistingModelEntitySet" ReturnType="Collection(MyOffer.UpdateAnExistingModelEntity)" d:EncodeParameterValues="true" d:AllowedHttpMethods="PUT" d:BaseUri=”http://services.organization.net/MyServicePath?name={name}&amp;AccountKey=22AC643">
    <d:Title d:Map="" />
    <d:Rights d:Map="" />
    <d:Description>Update an Existing Model</d:Description>
    <d:Headers>
    <d:Header d:Name="Content-Type" d:Value="application/xml;charset=UTF-8" />
    </d:Headers>
    <Parameter Name="name" Nullable="false" Mode="In" Type="String" d:Description="first name" d:SampleValues="John|Joe|Bill"  d:EncodeParameterValue="true" />
    <d:Namespaces>
    <d:Namespace d:Prefix="p" d:Uri="http://schemas.organization.net/2010/04/myNamespace " />
    <d:Namespace d:Prefix="p2" d:Uri=" http://schemas.organization.net/2010/04/myNamespace2 " />
    </d:Namespaces>
    </FunctionImport>
    <EntityType Name="UpdateAnExistingModelEntity" d:Map="//string">
    <Property Name="string"     Type="String" Nullable="true" d:Map="./string" />
    </EntityType>

Example: FunctionImport for "Raw" data returned using "PUT"

Use PUT Raw data to create a new subordinate or to update the entire subordinate at a server defined URL. Where the subordinate is a stream, i.e. unstructured, ex. a text file. PUT is idempotent so multiple occurrences will result in the same state, i.e x=5. Put should be used with the full content of the specified resource.

    <!--  No EntitySet or EntityType nodes required for Raw output-->
    <FunctionImport Name="CancelBuild” ReturnType="Raw(text/plain)" d:AllowedHttpMethods="PUT" d:EncodeParameterValues="true" d:BaseUri=” http://services.organization.net/MyServicePath?name={name}&amp;AccountKey=22AC643">
    <d:Title d:Map="" />
    <d:Rights d:Map="" />
    <d:Description>Cancel Build</d:Description>
    <d:Headers>
    <d:Header d:Name="Content-Type" d:Value="application/xml;charset=UTF-8" />
    </d:Headers>
    <Parameter Name="name" Nullable="false" Mode="In" Type="String" d:Description="first name" d:SampleValues="John|Joe|Bill"  d:EncodeParameterValue="true" />
    <d:Namespaces>
    <d:Namespace d:Prefix="p" d:Uri="http://schemas.organization.net/2010/04/myNamespace " />
    <d:Namespace d:Prefix="p2" d:Uri=" http://schemas.organization.net/2010/04/myNamespace2 " />
    </d:Namespaces>
    </FunctionImport>

Example: FunctionImport for "Raw" data returned using "GET"

Use GET Raw data to return a subordinate that is unstructured, i.e. text.

    <!--  No EntitySet or EntityType nodes required for Raw output-->
    <FunctionImport Name="GetModelUsageFile" ReturnType="Raw(text/plain)" d:EncodeParameterValues="true" d:AllowedHttpMethods="GET" d:BaseUri="https://cmla.cloudapp.net/api2/model/builder/build?buildId={buildId}&amp;apiVersion={apiVersion}">
    <d:Title d:Map="" />
    <d:Rights d:Map="" />
    <d:Description>Download A Models Usage File</d:Description>
    <d:Headers>
    <d:Header d:Name="Accept" d:Value="application/xml,application/xhtml+xml,text/html;" />
    <d:Header d:Name="Content-Type" d:Value="application/xml;charset=UTF-8" />
    </d:Headers>
    <Parameter Name="name" Nullable="false" Mode="In" Type="String" d:Description="first name" d:SampleValues="John|Joe|Bill"  d:EncodeParameterValue="true" />
    <d:Namespaces>
    <d:Namespace d:Prefix="p" d:Uri="http://schemas.organization.net/2010/04/myNamespace " />
    <d:Namespace d:Prefix="p2" d:Uri=" http://schemas.organization.net/2010/04/myNamespace2 " />
    </d:Namespaces>
    </FunctionImport>

Example: FunctionImport for "Paging" through returned data

Use implement RESTful paging through your data with GET. Default paging is set to 100 row per page of data.

    <EntitySet Name=”CropEntitySet" EntityType="MyOffer.CropEntity" />
    <FunctionImport    Name="GetCropReport" EntitySet="CropEntitySet” ReturnType="Collection(MyOffer.CropEntity)" d:EmitSelfLink="false" d:EncodeParameterValues="true" d:Paging="SkipTake" d:MaxPageSize="100" d:BaseUri="http://api.mydata.org/Crop? report={report}&amp;series={series}&amp;start={$skip}&amp;size=100">
    <Parameter Name="report" Type="Int32" Mode="In" Nullable="false" d:SampleValues="4"  d:enum="1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19"  />
    <Parameter Name="series"    Type="String"    Mode="In" Nullable="false" d:SampleValues="FARM" />
    <d:Headers>
    <d:Header d:Name="Content-Type" d:Value="text/xml;charset=UTF-8" />
    </d:Headers>
    <d:Namespaces>
    <d:Namespace d:Prefix="diffgr" d:Uri="urn:schemas-microsoft-com:xml-diffgram-v1" />
    </d:Namespaces>
    </FunctionImport>

See Also

  • If you are interested in understanding the overall OData mapping process and purpose, read this article Data Service OData Mapping to review definitions, structures, and instructions.
  • If you are interested in learning and understanding the specific nodes and their parameters, read this article Data Service OData Mapping Nodes for definitions and explanations, examples, and use case context.
  • To return to the prescribed path for publishing a Data Service to the Azure Marketplace, read this article Data Service Publishing Guide.