Esempio n. 1
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            RunCmdLet(() =>
            {
                List <ServiceAccessPolicyEntry> accessPolicies = GetAccessPolicies();

                ServicesDescription servicesDescription = new ServicesDescription()
                {
                    Kind     = GetKind(),
                    Location = Location,
                    Tags     = this.GetTags(),

                    Properties = new ServicesProperties()
                    {
                        AuthenticationConfiguration = new ServiceAuthenticationConfigurationInfo()
                        {
                            Authority = GetAuthority(), Audience = GetAudience(), SmartProxyEnabled = EnableSmartProxy.ToBool()
                        },
                        CosmosDbConfiguration = new ServiceCosmosDbConfigurationInfo()
                        {
                            OfferThroughput = GetCosmosDBThroughput()
                        },
                        CorsConfiguration = new ServiceCorsConfigurationInfo()
                        {
                            Origins = CorsOrigin, Headers = CorsHeader, Methods = CorsMethod, MaxAge = CorsMaxAge, AllowCredentials = AllowCorsCredential
                        },
                        AccessPolicies = accessPolicies
                    }
                };

                if (ShouldProcess(this.Name, Resources.createService))
                {
                    this.EnsureNameAvailabilityOrThrow();

                    try
                    {
                        var createAccountResponse = this.HealthcareApisClient.Services.CreateOrUpdate(
                            this.ResourceGroupName,
                            this.Name,
                            servicesDescription);


                        var healthCareFhirService = this.HealthcareApisClient.Services.Get(this.ResourceGroupName, this.Name);
                        WriteObject(healthCareFhirService);
                    }
                    catch (ErrorDetailsException wex)
                    {
                        WriteError(WriteErrorforBadrequest(wex));
                    }
                }
            });
        }
Esempio n. 2
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            RunCmdLet(() =>
            {
                if (AccessPolicyObjectId == null || AccessPolicyObjectId.Length == 0)
                {
                    AccessPolicyObjectId    = new string[1];
                    string objectID         = base.AccessPolicyID;
                    AccessPolicyObjectId[0] = objectID;
                }

                List <ServiceAccessPolicyEntry> accessPolicies = new List <ServiceAccessPolicyEntry>();
                foreach (string objectId in AccessPolicyObjectId)
                {
                    accessPolicies.Add(new ServiceAccessPolicyEntry(objectId));
                }

                ServicesDescription servicesDescription = new ServicesDescription()
                {
                    Kind     = GetKind(),
                    Location = Location,
                    Tags     = this.GetTags(),

                    Properties = new ServicesProperties()
                    {
                        AuthenticationConfiguration = new ServiceAuthenticationConfigurationInfo()
                        {
                            Authority = GetAuthority(), Audience = GetAudience(), SmartProxyEnabled = EnableSmartProxy.ToBool()
                        },
                        CosmosDbConfiguration = new ServiceCosmosDbConfigurationInfo()
                        {
                            OfferThroughput = GetCosmosDBThroughput()
                        },
                        CorsConfiguration = new ServiceCorsConfigurationInfo()
                        {
                            Origins = CorsOrigin, Headers = CorsHeader, Methods = CorsMethod, MaxAge = CorsMaxAge, AllowCredentials = AllowCorsCredential
                        },
                        AccessPolicies = accessPolicies
                    }
                };

                if (ShouldProcess(this.Name, Resources.createService))
                {
                    this.EnsureNameAvailabilityOrThrow();

                    var createAccountResponse = this.HealthcareApisClient.Services.CreateOrUpdate(
                        this.ResourceGroupName,
                        this.Name,
                        servicesDescription);

                    var healthCareFhirService = this.HealthcareApisClient.Services.Get(this.ResourceGroupName, this.Name);

                    WriteObject(healthCareFhirService);
                }
            });
        }
        public override void ExecuteCmdlet()
        {
            try
            {
                base.ExecuteCmdlet();

                RunCmdLet(() =>
                {
                    List <ServiceAccessPolicyEntry> accessPolicies = GetAccessPolicies();

                    ServicesDescription servicesDescription = new ServicesDescription()
                    {
                        Kind     = GetKind(),
                        Location = Location,
                        Tags     = this.GetTags(),

                        Properties = new ServicesProperties()
                        {
                            AuthenticationConfiguration = new ServiceAuthenticationConfigurationInfo()
                            {
                                Authority = GetAuthority(), Audience = GetAudience(), SmartProxyEnabled = EnableSmartProxy.ToBool()
                            },
                            CosmosDbConfiguration = new ServiceCosmosDbConfigurationInfo()
                            {
                                OfferThroughput = GetCosmosDBThroughput(), KeyVaultKeyUri = GetCosmosDBKeyVaultKeyUri()
                            },
                            CorsConfiguration = new ServiceCorsConfigurationInfo()
                            {
                                Origins = CorsOrigin, Headers = CorsHeader, Methods = CorsMethod, MaxAge = CorsMaxAge, AllowCredentials = AllowCorsCredential
                            },
                            ExportConfiguration = new ServiceExportConfigurationInfo()
                            {
                                StorageAccountName = ExportStorageAccountName
                            },
                            AccessPolicies = accessPolicies,
                        }
                    };

                    if (this.ManagedIdentity.IsPresent)
                    {
                        servicesDescription.Identity = new ServicesResourceIdentity()
                        {
                            Type = "SystemAssigned"
                        };
                    }

                    if (!string.IsNullOrEmpty(PublicNetworkAccess))
                    {
                        servicesDescription.Properties.PublicNetworkAccess = PublicNetworkAccess;
                    }

                    if (ShouldProcess(this.Name, Resources.createService))
                    {
                        this.EnsureNameAvailabilityOrThrow();

                        try
                        {
                            var createAccountResponse = this.HealthcareApisClient.Services.CreateOrUpdate(
                                this.ResourceGroupName,
                                this.Name,
                                servicesDescription);

                            var healthCareFhirService = this.HealthcareApisClient.Services.Get(this.ResourceGroupName, this.Name);
                            WriteHealthcareApisAccount(healthCareFhirService);
                        }
                        catch (ErrorDetailsException wex)
                        {
                            WriteError(WriteErrorforBadrequest(wex));
                        }
                    }
                });
            }
            catch (KeyNotFoundException ex)
            {
                WriteError(new ErrorRecord(ex, Resources.keyNotFoundExceptionMessage, ErrorCategory.OpenError, ex));
            }
            catch (NullReferenceException ex)
            {
                WriteError(new ErrorRecord(ex, Resources.nullPointerExceptionMessage, ErrorCategory.OpenError, ex));
            }
        }