def create_resource(resource_name, kind, sku_name, location): print("Creating resource: " + resource_name + "...") # NOTE If you do not want to use a custom subdomain name, remove the customSubDomainName # property from the properties object. parameters = Account(sku=Sku(name=sku_name), kind=kind, location=location, properties={'custom_sub_domain_name': subdomain_name}) poller = client.accounts.begin_create(resource_group_name, resource_name, parameters) while (False == poller.done()): print("Waiting {wait_time} seconds for operation to finish.".format( wait_time=wait_time)) time.sleep(wait_time) # This will raise an exception if the server responded with an error. result = poller.result() print("Resource created.") print() print("ID: " + result.id) print("Name: " + result.name) print("Type: " + result.type) print()
def update(client, resource_group_name, account_name, sku_name=None, tags=None): sku = Sku(name=sku_name) return client.update(resource_group_name, account_name, sku, tags)
def update(client, resource_group_name, account_name, sku_name=None, custom_domain=None, tags=None, api_properties=None, storage=None, encryption=None): if sku_name is None: sa = client.get(resource_group_name, account_name) sku_name = sa.sku.name sku = Sku(name=sku_name) properties = CognitiveServicesAccountProperties() if api_properties is not None: api_properties = CognitiveServicesAccountApiProperties.deserialize( api_properties) properties.api_properties = api_properties if custom_domain: properties.custom_sub_domain_name = custom_domain params = CognitiveServicesAccount(sku=sku, properties=properties, tags=tags) if storage is not None: params.properties.user_owned_storage = json.loads(storage) if encryption is not None: params.properties.encryption = json.loads(encryption) return client.begin_update(resource_group_name, account_name, params)
def create(client, resource_group_name, account_name, sku_name, kind, location, tags=None, yes=None): terms = 'Notice\nMicrosoft will use data you send to Bing Search Services'\ ' or the Translator Speech API to improve Microsoft products and services.'\ 'Where you send personal data to these Cognitive Services, you are responsible '\ 'for obtaining sufficient consent from the data subjects.'\ 'The General Privacy and Security Terms in the Online Services Terms '\ 'do not apply to these Cognitive Services.'\ 'Please refer to the Microsoft Cognitive Services section in the Online '\ 'Services Terms'\ ' (https://www.microsoft.com/en-us/Licensing/product-licensing/products.aspx)'\ ' for details.'\ 'Microsoft offers policy controls that may be used to disable new Cognitive'\ ' Services deployments (https://docs.microsoft.com/en-us/azure/cognitive-servic'\ 'es/cognitive-services-apis-create-account).' hint = '\nPlease select' if yes: logger.warning(terms) else: logger.warning(terms) option = prompt_y_n(hint) if not option: raise CLIError('Operation cancelled.') sku = Sku(sku_name) properties = {} params = CognitiveServicesAccountCreateParameters(sku, kind, location, properties, tags) return client.create(resource_group_name, account_name, params)
def create(client, resource_group_name, account_name, sku_name, kind, location, tags=None, yes=None): terms = 'Notice\nMicrosoft will use data you send to the Cognitive'\ 'Services to improve Microsoft products and services.'\ 'For example we may use content that you provide to the Cognitive'\ 'Services to improve our underlying algorithms and models over time.'\ 'Where you send personal data to the Cognitive Services, you are responsible'\ 'for obtaining sufficient consent from the data subjects.'\ 'The General Privacy and Security Terms in the Online Services Terms '\ '(https://www.microsoft.com/en-us/Licensing/product-licensing/products.aspx) '\ 'do not apply to the Cognitive Services.'\ 'You must comply with use and display requirements for the Bing Search APIs.'\ '\n\nPlease refer to the Microsoft Cognitive Services section in the Online '\ 'Services Terms for details.' hint = '\nPlease select' if yes: logger.warning(terms) else: logger.warning(terms) option = prompt_y_n(hint) if not option: raise CLIError('Operation cancelled.') sku = Sku(sku_name) properties = {} params = CognitiveServicesAccountCreateParameters(sku, kind, location, properties, tags) return client.create(resource_group_name, account_name, params)
def create_resource (resource_name, kind, sku_name, location): print("Creating resource: " + resource_name + "...") # The parameter "properties" must be an empty object. parameters = CognitiveServicesAccount(sku=Sku(name=sku_name), kind=kind, location=location, properties={}) result = client.accounts.create(resource_group_name, resource_name, parameters) print("Resource created.") print() print("ID: " + result.id) print("Name: " + result.name) print("Type: " + result.type) print()
def create(client, resource_group_name, account_name, sku_name, kind, location, custom_domain=None, tags=None, api_properties=None, yes=None): terms = 'Notice\nMicrosoft will use data you send to Bing Search Services'\ ' to improve Microsoft products and services.'\ 'Where you send personal data to these Cognitive Services, you are responsible '\ 'for obtaining sufficient consent from the data subjects.'\ 'The General Privacy and Security Terms in the Online Services Terms '\ 'do not apply to these Cognitive Services.'\ 'Please refer to the Microsoft Cognitive Services section in the Online '\ 'Services Terms'\ ' (https://www.microsoft.com/Licensing/product-licensing/products.aspx)'\ ' for details.'\ 'Microsoft offers policy controls that may be used to disable new Cognitive'\ ' Services deployments (https://docs.microsoft.com/azure/cognitive-servic'\ 'es/cognitive-services-apis-create-account).' hint = '\nPlease select' import re pattern = re.compile("^[Bb]ing\\..*$") if pattern.match(kind): if yes: logger.warning(terms) else: logger.warning(terms) option = prompt_y_n(hint) if not option: raise CLIError('Operation cancelled.') sku = Sku(name=sku_name) properties = {} if api_properties is not None: properties["apiProperties"] = api_properties if custom_domain: properties["customSubDomainName"] = custom_domain params = CognitiveServicesAccountCreateParameters(sku=sku, kind=kind, location=location, properties=properties, tags=tags) return client.create(resource_group_name, account_name, params)
def create_resource(resource_name, kind, sku_name, location): print("Creating resource: " + resource_name + "...") # NOTE If you do not want to use a custom subdomain name, remove the customSubDomainName # property from the properties object. parameters = CognitiveServicesAccount( sku=Sku(name=sku_name), kind=kind, location=location, properties={'custom_sub_domain_name': subdomain_name}) result = client.accounts.create(resource_group_name, resource_name, parameters) print("Resource created.") print() print("ID: " + result.id) print("Name: " + result.name) print("Type: " + result.type) print()
def update(client, resource_group_name, account_name, sku_name=None, custom_domain=None, tags=None, api_properties=None): if sku_name is None: sa = client.get_properties(resource_group_name, account_name) sku_name = sa.sku.name sku = Sku(name=sku_name) properties = {} if api_properties is not None: properties["apiProperties"] = api_properties if custom_domain: properties["customSubDomainName"] = custom_domain return client.update(resource_group_name, account_name, sku, tags, properties)
def create(client, resource_group_name, account_name, sku_name, kind, location, custom_domain=None, tags=None, api_properties=None, assign_identity=False, storage=None, encryption=None, yes=None): terms = 'Notice\nMicrosoft will use data you send to Bing Search Services'\ ' to improve Microsoft products and services.'\ 'Where you send personal data to these Cognitive Services, you are responsible '\ 'for obtaining sufficient consent from the data subjects.'\ 'The General Privacy and Security Terms in the Online Services Terms '\ 'do not apply to these Cognitive Services.'\ 'Please refer to the Microsoft Cognitive Services section in the Online '\ 'Services Terms'\ ' (https://www.microsoft.com/Licensing/product-licensing/products.aspx)'\ ' for details.'\ 'Microsoft offers policy controls that may be used to disable new Cognitive'\ ' Services deployments (https://docs.microsoft.com/azure/cognitive-servic'\ 'es/cognitive-services-apis-create-account).' terms_not_police = 'Notice\n' \ 'I certify that use of this service is not by or for a police department in the United States.' hint = 'Please select' import re pattern = re.compile("^[Bb]ing\\..*$") if pattern.match(kind): if yes: logger.warning(terms) else: logger.warning(terms) option = prompt_y_n(hint) if not option: raise CLIError('Operation cancelled.') if kind.lower() == 'face' or kind.lower() == 'cognitiveservices': if yes: logger.warning(terms_not_police) else: logger.warning(terms_not_police) option = prompt_y_n(hint) if not option: raise CLIError('Operation cancelled.') sku = Sku(name=sku_name) properties = CognitiveServicesAccountProperties() if api_properties is not None: api_properties = CognitiveServicesAccountApiProperties.deserialize( api_properties) properties.api_properties = api_properties if custom_domain: properties.custom_sub_domain_name = custom_domain params = CognitiveServicesAccount(sku=sku, kind=kind, location=location, properties=properties, tags=tags) if assign_identity: params.identity = Identity(type=IdentityType.system_assigned) if storage is not None: params.properties.user_owned_storage = json.loads(storage) if encryption is not None: params.properties.encryption = json.loads(encryption) return client.begin_create(resource_group_name, account_name, params)