/// <summary> /// Get the path for the arm template file on Azure Storage /// </summary> /// <param name="offer"></param> /// <param name="plan"></param> /// <param name="subscriptionAction"></param> /// <returns>File path for the template file on blob storage</returns> public async Task <string> GetTemplatePath( Offer offer, Plan plan, FulfillmentAction subscriptionAction ) { ArmTemplate template = null; switch (subscriptionAction) { case FulfillmentAction.Activate: template = await _lunaClient.GetArmTemplate(offer.OfferName, plan.SubscribeArmTemplateName); break; case FulfillmentAction.Update: template = await _lunaClient.GetArmTemplate(offer.OfferName, plan.SubscribeArmTemplateName); break; case FulfillmentAction.Unsubscribe: template = await _lunaClient.GetArmTemplate(offer.OfferName, plan.UnsubscribeArmTemplateName); break; default: throw new InvalidEnumArgumentException(); } return(template.TemplateFilePath); }
/// <summary> /// Parse the ARM template to get the parameter names and build an object containing the parameter names and values /// </summary> /// <param name="offer"></param> /// <param name="plan"></param> /// <param name="subscriptionAction"></param> /// <returns>An object containing the parameter names and values</returns> public async Task <Dictionary <string, object> > GetTemplateParameters( Offer offer, Plan plan, FulfillmentAction subscriptionAction ) { ArmTemplate template = null; switch (subscriptionAction) { case FulfillmentAction.Activate: template = await _lunaClient.GetArmTemplate(offer.OfferName, plan.SubscribeArmTemplateName); break; case FulfillmentAction.Update: template = await _lunaClient.GetArmTemplate(offer.OfferName, plan.SubscribeArmTemplateName); break; case FulfillmentAction.Unsubscribe: template = await _lunaClient.GetArmTemplate(offer.OfferName, plan.UnsubscribeArmTemplateName); break; default: throw new InvalidEnumArgumentException(); } string templateContent = await _storage.DownloadToTextAsync(template.TemplateFilePath); var parameters = ARMTemplateHelper.GetArmTemplateParameters(templateContent); var parameterList = new Dictionary <string, object>(); foreach (var parameter in parameters) { ArmTemplateParameter atp = await _lunaClient.GetArmTemplateParameter(offer.OfferName, parameter.Key); parameterList.Add( atp.Name, new { Value = atp.Value } ); } return(parameterList); }