Skip to content

Instantly share code, notes, and snippets.

View krishrocks1904's full-sized avatar
👋

Rakesh Suryawanshi krishrocks1904

👋
View GitHub Profile
@krishrocks1904
krishrocks1904 / addNewPolicy.ps1
Last active August 1, 2020 17:25
Script help to add policies to product and API both depends on the parameter.
function Add-NewPolicy {
param ($ApiMgmtContext, $product, $addPolicyToProduct, $policy, $apiId)
Write-Host "**************************** Add-NewPolicy *******************************"
Write-Host "[POLICY] Policy name :: $($policy.path)"
Get-Location
$policies = (Get-ChildItem ../**/**.* -Recurse -filter $policy.path)
@krishrocks1904
krishrocks1904 / apim-input.json
Created July 31, 2020 10:44
json file to deploy api into api management
{
"apimInput": [
{
"id": "your product id",
"title": "product title",
"description": "product description",
"product_legal_terms": "product legal term and condition leave it blank",
"subscription_requires": true,
"apis": [
{
@krishrocks1904
krishrocks1904 / getapi.ps1
Created July 31, 2020 10:41
Find a API from API Management
################################### FIND API ################################
function Get-API {
param ($ApiMgmtContext, $api)
Write-Host "[FIND API] Searching for Api :: '$($api.name)' ..." -ForegroundColor Green
$getApimApiParams = @{
Context =$ApiMgmtContext
ApiId =$api.api_name
}
@krishrocks1904
krishrocks1904 / addProductToGroup.ps1
Created July 31, 2020 10:21
This method call Add-ProductToGroup method to add Product to a product group
################################### Method to Add Product to Group 'Add-ProductToGroup' ################################
function Add-ProductToGroup {
param ($ApiMgmtContext, $product, $groupName)
Write-Host "**************************** Add-ProductToGroup *******************************"
Write-Host "[LINK-PRODUCT-TO-PRODUCT-GROUP] Working on Adding product to Product group :: '$($product.id)' to '$($groupName)' group..."
$getApimGroupParams = @{
Context =$ApiMgmtContext
ProductId =$product.product_id
Name = $groupName
@krishrocks1904
krishrocks1904 / addNewAPIMProduct.ps1
Created July 31, 2020 10:18
Add new Product to API
################################### Method to Add New product ################################
function Add-NewAPIMProduct {
param ($ApiMgmtContext, $product)
Write-Host "**************************** Add-NewAPIMProduct *******************************"
$getApimProductParams = @{
Context =$ApiMgmtContext
ProductId =$product.id
@krishrocks1904
krishrocks1904 / addNewApiVersion.ps1
Created July 31, 2020 10:16
Add new API Version to APIM
################################### Method to New API Version ################################
function Add-NewApiVersion {
param($ApiMgmtContext,$apiName,$displayName, $apiVersion, $path,$apiSpecificationPath,$serviceUrl, $revision)
$versionSetLookup = Get-AzApiManagementApiVersionSet -Context $ApiMgmtContext | Where-Object { $_.DisplayName -eq "$apiName" } | Sort-Object -Property ApiVersionSetId -Descending | Select-Object -first 1
if($versionSetLookup -eq $null)
{
$newApimApiVersionSetParams = @{
Context = $ApiMgmtContext
################################### Method to Add Product to Group 'Add-ProductToGroup' ################################
function Add-NewAPI {
param ($ApiMgmtContext, $product, $api)
Write-Host "**************************** Add-NewAPI*******************************"
# Powershell returns API name value in API_Id field
$reverionSchemaFiles = (Get-ChildItem ../**/**.* -Recurse -filter $api.api_path)
if($reverionSchemaFiles.Count -gt 0)
{
@krishrocks1904
krishrocks1904 / deployment.ps1
Last active July 31, 2020 10:46
Web API deployment into Azure API Management
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$resource_group_name = "your-resource_group-name",
[string]$apim_name = "apim-name"
)
$SpecificationFormat="OpenApi"
$apiProtocols = @('https')
$publishedState ="Published"